Better error messages for vararg-table fields

This commit is contained in:
Roberto I
2026-04-13 14:06:23 -03:00
parent 29cf284089
commit d0bd25d2e7
2 changed files with 4 additions and 1 deletions

View File

@@ -580,7 +580,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
kname(p, k, name);
return isEnv(p, lastpc, i, 1);
}
case OP_GETTABLE: {
case OP_GETTABLE: case OP_GETVARG: {
int k = GETARG_C(i); /* key index */
rname(p, lastpc, k, name);
return isEnv(p, lastpc, i, 0);

View File

@@ -159,6 +159,9 @@ assert(not string.find(doit"aaa={13}; local bbbb=1; aaa[bbbb](3)", "'bbbb'"))
checkmessage("aaa={13}; local bbbb=1; aaa[bbbb](3)", "number")
checkmessage("aaa=(1)..{}", "a table value")
checkmessage("local function foo (...t) return t.xx + 1 end; foo()",
"field 'xx'")
-- bug in 5.4.6
checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'")