Cleanup; add test

This commit is contained in:
Pranav Gaddamadugu 2022-08-05 14:53:55 -07:00
parent d397c750d2
commit a47eb32eaf
5 changed files with 43 additions and 6 deletions

View File

@ -83,10 +83,10 @@ impl<'a> CodeGenerator<'a> {
closures.push_str(&function_string);
closures.push('\n');
}
});
// Unset the `is_program_function` flag.
self.is_program_function = false;
// Unset the `is_program_function` flag.
self.is_program_function = false;
});
// Closures must precede functions in the Aleo program.
program_string.push_str(&closures);
@ -187,9 +187,6 @@ impl<'a> CodeGenerator<'a> {
let block_string = self.visit_block(&function.block);
function_string.push_str(&block_string);
// Unset `is_program_function` after visiting `function`.
self.is_program_function = false;
function_string
}
}

View File

@ -0,0 +1,28 @@
---
namespace: Parse
expectation: Pass
outputs:
- name: ""
network: ""
expected_input: []
imports: {}
functions:
"{\"name\":\"test\",\"span\":\"{\\\"lo\\\":94,\\\"hi\\\":98}\"}":
annotations:
- identifier: "{\"name\":\"test\",\"span\":\"{\\\"lo\\\":79,\\\"hi\\\":83}\"}"
span:
lo: 78
hi: 83
identifier: "{\"name\":\"test\",\"span\":\"{\\\"lo\\\":94,\\\"hi\\\":98}\"}"
input: []
output: U8
core_mapping: ~
block:
statements: []
span:
lo: 107
hi: 109
span:
lo: 85
hi: 109
circuits: {}

View File

@ -0,0 +1,5 @@
---
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370028]: Illegal spacing in the annotation declaration.\n --> test:3:1\n |\n 3 | @ test\n | ^^^^^^\n |\n = Remove whitespace between the `@` symbol and the identifier."

View File

@ -0,0 +1,7 @@
/*
namespace: Parse
expectation: Fail
*/
@ test
function test() -> u8 {}