Bug: 'local function' can assign to '<const>' variables
This commit is contained in:
@@ -1785,6 +1785,7 @@ static void funcstat (LexState *ls, int line) {
|
|||||||
luaX_next(ls); /* skip FUNCTION */
|
luaX_next(ls); /* skip FUNCTION */
|
||||||
ismethod = funcname(ls, &v);
|
ismethod = funcname(ls, &v);
|
||||||
body(ls, &b, ismethod, line);
|
body(ls, &b, ismethod, line);
|
||||||
|
check_readonly(ls, &v);
|
||||||
luaK_storevar(ls->fs, &v, &b);
|
luaK_storevar(ls->fs, &v, &b);
|
||||||
luaK_fixline(ls->fs, line); /* definition "happens" in the first line */
|
luaK_fixline(ls->fs, line); /* definition "happens" in the first line */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,8 @@ do -- constants
|
|||||||
checkro("y", "local x, y <const>, z = 10, 20, 30; x = 11; y = 12")
|
checkro("y", "local x, y <const>, z = 10, 20, 30; x = 11; y = 12")
|
||||||
checkro("x", "local x <const>, y, z <const> = 10, 20, 30; x = 11")
|
checkro("x", "local x <const>, y, z <const> = 10, 20, 30; x = 11")
|
||||||
checkro("z", "local x <const>, y, z <const> = 10, 20, 30; y = 10; z = 11")
|
checkro("z", "local x <const>, y, z <const> = 10, 20, 30; y = 10; z = 11")
|
||||||
|
checkro("foo", "local foo <const> = 10; function foo() end")
|
||||||
|
checkro("foo", "local foo <const> = {}; function foo() end")
|
||||||
|
|
||||||
checkro("z", [[
|
checkro("z", [[
|
||||||
local a, z <const>, b = 10;
|
local a, z <const>, b = 10;
|
||||||
|
|||||||
Reference in New Issue
Block a user