From f20b56ff64b3144d618d228fbe1a3d07aad96450 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 11 May 2021 17:23:24 +0200 Subject: compiler: properly parse slashes in parenthesized division expressions Due to the special code path parsing the leading label portion of a parenthesized expression, slashes following a label were improperly treated as regular expression literal delimitters, emitting a syntax error when an otherwise valid expression such as `a / 1` was being parsed as first sub expression of a parenthesized expression. Signed-off-by: Jo-Philipp Wich --- .../custom/03_bugs/22_compiler_parenthesized_division | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/custom/03_bugs/22_compiler_parenthesized_division (limited to 'tests/custom/03_bugs') diff --git a/tests/custom/03_bugs/22_compiler_parenthesized_division b/tests/custom/03_bugs/22_compiler_parenthesized_division new file mode 100644 index 0000000..a70703f --- /dev/null +++ b/tests/custom/03_bugs/22_compiler_parenthesized_division @@ -0,0 +1,19 @@ +When compiling a parenthesized division or division-assignment expression, +the compiler didn't instruct the lexer to treat a potential subsequent +slash as operand, leading to an incorrect syntax error exception. + +-- Expect stdout -- +0 +0 +0 +0 +-- End -- + +-- Testcase -- +{% + print(a / 1, "\n"); // this was okay + print(a /= 1, "\n"); // okay too + print((a / 1), "\n"); // this failed + print((a /= 1), "\n"); // failed as well +%} +-- End -- -- cgit v1.2.3