8050c84
diff -up lua-5.4.3/lua-5.4.3-tests/locals.lua.bug4 lua-5.4.3/lua-5.4.3-tests/locals.lua
8050c84
--- lua-5.4.3/lua-5.4.3-tests/locals.lua.bug4	2022-01-24 11:21:11.757660851 -0500
8050c84
+++ lua-5.4.3/lua-5.4.3-tests/locals.lua	2022-01-24 11:21:34.088788271 -0500
8050c84
@@ -187,6 +187,8 @@ do   -- constants
8050c84
   checkro("y", "local x, y <const>, z = 10, 20, 30; x = 11; y = 12")
8050c84
   checkro("x", "local x <const>, y, z <const> = 10, 20, 30; x = 11")
8050c84
   checkro("z", "local x <const>, y, z <const> = 10, 20, 30; y = 10; z = 11")
8050c84
+  checkro("foo", "local foo <const> = 10; function foo() end")
8050c84
+  checkro("foo", "local foo <const> = {}; function foo() end")
8050c84
 
8050c84
   checkro("z", [[
8050c84
     local a, z <const>, b = 10;
8050c84
diff -up lua-5.4.3/src/lparser.c.bug4 lua-5.4.3/src/lparser.c
8050c84
--- lua-5.4.3/src/lparser.c.bug4	2022-01-24 11:20:27.808410077 -0500
8050c84
+++ lua-5.4.3/src/lparser.c	2022-01-24 11:20:49.592534377 -0500
8050c84
@@ -1776,6 +1776,7 @@ static void funcstat (LexState *ls, int
8050c84
   luaX_next(ls);  /* skip FUNCTION */
8050c84
   ismethod = funcname(ls, &v);
8050c84
   body(ls, &b, ismethod, line);
8050c84
+  check_readonly(ls, &v);
8050c84
   luaK_storevar(ls->fs, &v, &b);
8050c84
   luaK_fixline(ls->fs, line);  /* definition "happens" in the first line */
8050c84
 }