From 2b9ba0becfb397349238ec4b8d8c3017b4428d11 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Fri, 5 Jul 2024 08:36:57 -0700 Subject: [PATCH 1/2] Fix expected list in parser error. This was missing a few alternatives. --- compiler/parser/src/parser/file.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 06d844a987..35a9e9c6e2 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -136,7 +136,7 @@ impl 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 { @@ -146,13 +146,16 @@ impl 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()); } From 9639c5b1c1e302f85adc2d4f64e6d1334e7fe120 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Mon, 8 Jul 2024 09:48:50 -0700 Subject: [PATCH 2/2] Adjust some text expectations. --- tests/expectations/parser/finalize/finalize_fail.out | 2 +- tests/expectations/parser/functions/ident_token_fail.out | 2 +- tests/expectations/parser/functions/test_keyword_fail.out | 2 +- tests/expectations/parser/program/circuit_deprecated_fail.out | 2 +- tests/expectations/parser/program/mapping_fail.out | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/expectations/parser/finalize/finalize_fail.out b/tests/expectations/parser/finalize/finalize_fail.out index 459d84d50d..c648822a9a 100644 --- a/tests/expectations/parser/finalize/finalize_fail.out +++ b/tests/expectations/parser/finalize/finalize_fail.out @@ -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 | ^^^^^^^^" diff --git a/tests/expectations/parser/functions/ident_token_fail.out b/tests/expectations/parser/functions/ident_token_fail.out index a034d20dc4..33283f860f 100644 --- a/tests/expectations/parser/functions/ident_token_fail.out +++ b/tests/expectations/parser/functions/ident_token_fail.out @@ -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 | ^" diff --git a/tests/expectations/parser/functions/test_keyword_fail.out b/tests/expectations/parser/functions/test_keyword_fail.out index b4e98eef56..de79c01227 100644 --- a/tests/expectations/parser/functions/test_keyword_fail.out +++ b/tests/expectations/parser/functions/test_keyword_fail.out @@ -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 | ^^^^" diff --git a/tests/expectations/parser/program/circuit_deprecated_fail.out b/tests/expectations/parser/program/circuit_deprecated_fail.out index f3f19c147a..b1dd4715b0 100644 --- a/tests/expectations/parser/program/circuit_deprecated_fail.out +++ b/tests/expectations/parser/program/circuit_deprecated_fail.out @@ -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 | ^^^^^^^" diff --git a/tests/expectations/parser/program/mapping_fail.out b/tests/expectations/parser/program/mapping_fail.out index 233b09e314..c675f52513 100644 --- a/tests/expectations/parser/program/mapping_fail.out +++ b/tests/expectations/parser/program/mapping_fail.out @@ -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 | ^^^^^^"