From f0a987503cb55f438a79c6d14058b23c5b801a0c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 4 May 2021 18:12:14 +0200 Subject: compiler: properly handle keyword in parenthesized property access expression Due to the special code path parsing the leading label portion of a parenthesized expression, keywords following a property access operator (TK_DOT, `.`) weren't properly handled, emitting a syntax error when an otherwise valid expression such as `value.default` was being parsed as first sub expression of a parenthesized expression. Signed-off-by: Jo-Philipp Wich --- .../03_bugs/21_compiler_parenthesized_prop_keyword | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/custom/03_bugs/21_compiler_parenthesized_prop_keyword (limited to 'tests/custom/03_bugs') diff --git a/tests/custom/03_bugs/21_compiler_parenthesized_prop_keyword b/tests/custom/03_bugs/21_compiler_parenthesized_prop_keyword new file mode 100644 index 0000000..472b2af --- /dev/null +++ b/tests/custom/03_bugs/21_compiler_parenthesized_prop_keyword @@ -0,0 +1,17 @@ +When compiling a parenthesized property access expression, the compiler +didn't instruct the lexer to treat a potential subsequent keyword as label, +leading to an incorrect syntax error exception. + +-- Expect stdout -- +true +true +-- End -- + +-- Testcase -- +{% + let x = { default: true }; + + print(x.default, "\n"); // this was okay + print((x.default), "\n"); // this failed +%} +-- End -- -- cgit v1.2.3