Correct line in error message for constant function
This commit is contained in:
@@ -1858,8 +1858,8 @@ static void funcstat (LexState *ls, int line) {
|
|||||||
expdesc v, b;
|
expdesc v, b;
|
||||||
luaX_next(ls); /* skip FUNCTION */
|
luaX_next(ls); /* skip FUNCTION */
|
||||||
ismethod = funcname(ls, &v);
|
ismethod = funcname(ls, &v);
|
||||||
body(ls, &b, ismethod, line);
|
|
||||||
check_readonly(ls, &v);
|
check_readonly(ls, &v);
|
||||||
|
body(ls, &b, ismethod, line);
|
||||||
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 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,6 +342,13 @@ do
|
|||||||
global foo <const>;
|
global foo <const>;
|
||||||
function foo (x) return end -- ERROR: foo is read-only
|
function foo (x) return end -- ERROR: foo is read-only
|
||||||
]], "assign to const variable 'foo'")
|
]], "assign to const variable 'foo'")
|
||||||
|
|
||||||
|
checkerr([[
|
||||||
|
global foo <const>;
|
||||||
|
function foo (x) -- ERROR: foo is read-only
|
||||||
|
return
|
||||||
|
end
|
||||||
|
]], "%:2%:") -- correct line in error message
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user