diff options
-rw-r--r-- | compiler.c | 4 | ||||
-rw-r--r-- | tests/custom/03_bugs/21_compiler_parenthesized_prop_keyword | 17 |
2 files changed, 21 insertions, 0 deletions
@@ -1193,6 +1193,10 @@ uc_compiler_compile_paren(uc_compiler *compiler, bool assignable) uc_compiler_parse_advance(compiler); } + /* If we encouter a dot, treat potential subsequent keyword as label */ + if (uc_compiler_parse_check(compiler, TK_DOT)) + compiler->parser->lex.no_keyword = true; + break; } } 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 -- |