Skip to content

Commit

Permalink
Merge pull request #28198 from ProvableHQ/fix/parser-error-data
Browse files Browse the repository at this point in the history
Fix expected list in parser error.
  • Loading branch information
evan-schott authored Jul 8, 2024
2 parents 1e77f75 + 9639c5b commit edb3c8e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion compiler/parser/src/parser/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<N: Network> ParserContext<'_, N> {
Token::At | Token::Async | Token::Function | Token::Transition | Token::Inline => {
let (id, function) = self.parse_function()?;

// Partition into transitions and functions so that don't have to sort later.
// Partition into transitions and functions so that we don't have to sort later.
if function.variant.is_transition() {
transitions.push((id, function));
} else {
Expand All @@ -147,13 +147,16 @@ impl<N: Network> ParserContext<'_, N> {
Token::RightCurly => break,
_ => {
return Err(Self::unexpected_item(&self.token, &[
Token::Const,
Token::Struct,
Token::Record,
Token::Mapping,
Token::At,
Token::Async,
Token::Function,
Token::Transition,
Token::Inline,
Token::RightCurly,
])
.into());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/parser/finalize/finalize_fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'struct', 'record', 'mapping', '@', 'function', 'transition', 'inline' -- found 'finalize'\n --> test:6:7\n |\n 6 | } finalize {\n | ^^^^^^^^"
- "Error [EPAR0370005]: expected 'const', 'struct', 'record', 'mapping', '@', 'async', 'function', 'transition', 'inline', '}' -- found 'finalize'\n --> test:6:7\n |\n 6 | } finalize {\n | ^^^^^^^^"
2 changes: 1 addition & 1 deletion tests/expectations/parser/functions/ident_token_fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'struct', 'record', 'mapping', '@', 'function', 'transition', 'inline' -- found '1'\n --> test:4:5\n |\n 4 | 1 main() {}}\n | ^"
- "Error [EPAR0370005]: expected 'const', 'struct', 'record', 'mapping', '@', 'async', 'function', 'transition', 'inline', '}' -- found '1'\n --> test:4:5\n |\n 4 | 1 main() {}}\n | ^"
2 changes: 1 addition & 1 deletion tests/expectations/parser/functions/test_keyword_fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'struct', 'record', 'mapping', '@', 'function', 'transition', 'inline' -- found 'test'\n --> test:4:5\n |\n 4 | test main() {}}\n | ^^^^"
- "Error [EPAR0370005]: expected 'const', 'struct', 'record', 'mapping', '@', 'async', 'function', 'transition', 'inline', '}' -- found 'test'\n --> test:4:5\n |\n 4 | test main() {}}\n | ^^^^"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'struct', 'record', 'mapping', '@', 'function', 'transition', 'inline' -- found 'circuit'\n --> test:5:5\n |\n 5 | circuit Foo {\n | ^^^^^^^"
- "Error [EPAR0370005]: expected 'const', 'struct', 'record', 'mapping', '@', 'async', 'function', 'transition', 'inline', '}' -- found 'circuit'\n --> test:5:5\n |\n 5 | circuit Foo {\n | ^^^^^^^"
2 changes: 1 addition & 1 deletion tests/expectations/parser/program/mapping_fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected 'struct', 'record', 'mapping', '@', 'function', 'transition', 'inline' -- found 'mappin'\n --> test:4:5\n |\n 4 | mappin balances: address => u128;\n | ^^^^^^"
- "Error [EPAR0370005]: expected 'const', 'struct', 'record', 'mapping', '@', 'async', 'function', 'transition', 'inline', '}' -- found 'mappin'\n --> test:4:5\n |\n 4 | mappin balances: address => u128;\n | ^^^^^^"

0 comments on commit edb3c8e

Please sign in to comment.