From 6ca33260d26f1b8fab982b13c89de1f445361328 Mon Sep 17 00:00:00 2001 From: Roberto I Date: Mon, 13 Jul 2026 15:18:37 -0300 Subject: Removed compiler option LUA_COMPAT_LOOPVAR It makes loop variables read-only, but it does not restore the old semantics, so it is not helpful for compatibility. --- lparser.c | 13 ++----------- luaconf.h | 9 --------- manual/manual.of | 3 --- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/lparser.c b/lparser.c index af2b64d1..fe29194c 100644 --- a/lparser.c +++ b/lparser.c @@ -1685,22 +1685,13 @@ static void forbody (LexState *ls, int base, int line, int nvars, int isgen) { } -/* -** Control whether for-loop control variables are read-only -*/ -#if LUA_COMPAT_LOOPVAR -#define LOOPVARKIND VDKREG -#else /* by default, these variables are read only */ -#define LOOPVARKIND RDKCONST -#endif - static void fornum (LexState *ls, TString *varname, int line) { /* fornum -> NAME = exp,exp[,exp] forbody */ FuncState *fs = ls->fs; int base = fs->freereg; new_localvarliteral(ls, "(for state)"); new_localvarliteral(ls, "(for state)"); - new_varkind(ls, varname, LOOPVARKIND); /* control variable */ + new_varkind(ls, varname, RDKCONST); /* control variable */ checknext(ls, '='); exp1(ls); /* initial value */ checknext(ls, ','); @@ -1727,7 +1718,7 @@ static void forlist (LexState *ls, TString *indexname) { new_localvarliteral(ls, "(for state)"); /* iterator function */ new_localvarliteral(ls, "(for state)"); /* state */ new_localvarliteral(ls, "(for state)"); /* closing var. (after swap) */ - new_varkind(ls, indexname, LOOPVARKIND); /* control variable */ + new_varkind(ls, indexname, RDKCONST); /* control variable */ /* other declared variables */ while (testnext(ls, ',')) { new_localvar(ls, str_checkname(ls)); diff --git a/luaconf.h b/luaconf.h index 0a71370f..042932e1 100644 --- a/luaconf.h +++ b/luaconf.h @@ -348,15 +348,6 @@ #endif -/* -@@ LUA_COMPAT_LOOPVAR makes for-loop control variables not read-only, -** as they were in previous versions. -*/ -#if !defined(LUA_COMPAT_LOOPVAR) -#define LUA_COMPAT_LOOPVAR 0 -#endif - - /* @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated ** functions in the mathematical library. diff --git a/manual/manual.of b/manual/manual.of index 5e113336..65261695 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -9623,9 +9623,6 @@ makes @id{global} a regular word. The control variable in @Rw{for} loops is read only. If you need to change it, declare a local variable with the same name in the loop body. - -The compilation option @id{LUA_COMPAT_LOOPVAR} (see @id{luaconf.h}) -makes these variables regular (writable). } @item{ -- cgit v1.2.3-55-g6feb