From 7dc6aae29057c9dc4588f780c7abd72a62ff4c8e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 12 May 2025 11:42:45 -0300 Subject: Correct line in error message for constant function --- lparser.c | 2 +- testes/goto.lua | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lparser.c b/lparser.c index 3c2f57ab..93991cb0 100644 --- a/lparser.c +++ b/lparser.c @@ -1858,8 +1858,8 @@ static void funcstat (LexState *ls, int line) { expdesc v, b; luaX_next(ls); /* skip FUNCTION */ ismethod = funcname(ls, &v); - body(ls, &b, ismethod, line); check_readonly(ls, &v); + body(ls, &b, ismethod, line); luaK_storevar(ls->fs, &v, &b); luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ } diff --git a/testes/goto.lua b/testes/goto.lua index b41399ff..59713dd7 100644 --- a/testes/goto.lua +++ b/testes/goto.lua @@ -342,6 +342,13 @@ do global foo ; function foo (x) return end -- ERROR: foo is read-only ]], "assign to const variable 'foo'") + + checkerr([[ + global foo ; + function foo (x) -- ERROR: foo is read-only + return + end + ]], "%:2%:") -- correct line in error message end -- cgit v1.2.3-55-g6feb