mirror of
https://github.com/lua/lua.git
synced 2026-09-09 03:48:07 +00:00
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.
This commit is contained in:
13
lparser.c
13
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));
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user