Fixed issue: #74

This commit is contained in:
UnlegitDqrk
2026-03-02 14:14:14 +01:00
parent c60991a33c
commit 9cb10a390f
3 changed files with 21 additions and 1 deletions

View File

@@ -1393,7 +1393,7 @@ public class LexState extends Constants {
return;
}
default: {
this.syntaxerror("unexpected symbol " + t.token + " (" + ((char) t.token) + ")");
this.syntaxerror("unexpected symbol near " + txtToken(t.token));
return;
}
}

View File

@@ -189,6 +189,26 @@ public class FragmentsTest extends TestSuite {
assertEquals("interrupted", thrown.get().getMessage());
}
public void testBareExpressionReportsReadableToken() {
Globals globals = JsePlatform.debugGlobals();
try {
globals.load("1 + 1", "expr.lua");
fail("expected syntax error");
} catch (LuaError e) {
assertTrue(e.getMessage().contains("unexpected symbol near 1"));
}
}
public void testUnfinishedTableReportsEof() {
Globals globals = JsePlatform.debugGlobals();
try {
globals.load("mytab = {", "table.lua");
fail("expected syntax error");
} catch (LuaError e) {
assertTrue(e.getMessage().contains("near <eof>"));
}
}
public void testLongIntegerLiteralPrecision() {
runFragment(
LuaValue.varargsOf(new LuaValue[] {