Case VVARGIND added to luaK_storevar
In a global initialization, the variable does not pass through 'check_readonly', and therefore a VVARGIND is not normalized to a VINDEXED.
This commit is contained in:
4
lcode.c
4
lcode.c
@@ -1109,6 +1109,10 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
|
||||
codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex);
|
||||
break;
|
||||
}
|
||||
case VVARGIND: {
|
||||
fs->f->flag |= PF_VATAB; /* function will need a vararg table */
|
||||
/* now, assignment is to a regular table */
|
||||
} /* FALLTHROUGH */
|
||||
case VINDEXED: {
|
||||
codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex);
|
||||
break;
|
||||
|
||||
@@ -184,6 +184,18 @@ do -- _ENV as vararg parameter
|
||||
a = 10
|
||||
end ]]
|
||||
assert(string.find(msg, "const variable 'a'"))
|
||||
|
||||
local function aux (... | _ENV)
|
||||
global a; a = 10
|
||||
return a
|
||||
end
|
||||
assert(aux() == 10)
|
||||
|
||||
local function aux (... | _ENV)
|
||||
global a = 10
|
||||
return a
|
||||
end
|
||||
assert(aux() == 10)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user