fix: detect missing closing brace in block parsing to prevent crash

The compiler previously relied on `match(TOKEN_RIGHT_BRACE)` in the while loop condition, which consumed the brace and made it impossible to detect a missing one. Changed to peek-based loop termination and added explicit `consume` call for the closing brace, ensuring proper error reporting when '}' is absent. Added regression test for issue #429.
This commit is contained in:
Bob Nystrom
2017-10-08 17:03:42 +00:00
parent 623cc454e5
commit bd31425b5f
2 changed files with 9 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
// The missing "}" was not detected by the compiler and reported as an error,
// so it then tried to run the resulting erroneous bytecode and crashed.
// expect error line 6
{
System