diff --git a/src/compiler.c b/src/compiler.c index 4d615441..28379eaf 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -244,8 +244,7 @@ ObjBlock* compileBlock(Parser* parser, Compiler* parent, TokenType endToken) { statement(&compiler); - consume(&compiler, TOKEN_LINE); - + if (!match(&compiler, TOKEN_LINE)) break; if (match(&compiler, endToken)) break; // Discard the result of the previous expression. diff --git a/test/no_trailing_newline.wren b/test/no_trailing_newline.wren new file mode 100644 index 00000000..9ec390d3 --- /dev/null +++ b/test/no_trailing_newline.wren @@ -0,0 +1 @@ +io.write("ok") // expect: ok \ No newline at end of file