mirror of https://github.com/rusefi/lua.git
Bug: Lua can generate wrong code when _ENV is <const>
This commit is contained in:
parent
25b143dd34
commit
1f3c6f4534
|
@ -468,6 +468,7 @@ static void singlevar (LexState *ls, expdesc *var) {
|
||||||
expdesc key;
|
expdesc key;
|
||||||
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
|
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
|
||||||
lua_assert(var->k != VVOID); /* this one must exist */
|
lua_assert(var->k != VVOID); /* this one must exist */
|
||||||
|
luaK_exp2anyregup(fs, var); /* but could be a constant */
|
||||||
codestring(&key, varname); /* key is variable name */
|
codestring(&key, varname); /* key is variable name */
|
||||||
luaK_indexed(fs, var, &key); /* env[varname] */
|
luaK_indexed(fs, var, &key); /* env[varname] */
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,6 +434,16 @@ a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 ==
|
||||||
10)
|
10)
|
||||||
|
|
||||||
|
|
||||||
|
do
|
||||||
|
-- _ENV constant
|
||||||
|
local function foo ()
|
||||||
|
local _ENV <const> = 11
|
||||||
|
X = "hi"
|
||||||
|
end
|
||||||
|
local st, msg = pcall(foo)
|
||||||
|
assert(not st and string.find(msg, "number"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- test of large float/integer indices
|
-- test of large float/integer indices
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue