diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-07-13 15:18:37 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-07-13 15:18:37 -0300 |
| commit | 6ca33260d26f1b8fab982b13c89de1f445361328 (patch) | |
| tree | 8c482c024f28adb451f18a65d851ab96361f78e5 /lparser.c | |
| parent | b996f8fd1be7fb711cc6f754a31a1c87d2c2fd9b (diff) | |
| download | lua-6ca33260d26f1b8fab982b13c89de1f445361328.tar.gz lua-6ca33260d26f1b8fab982b13c89de1f445361328.tar.bz2 lua-6ca33260d26f1b8fab982b13c89de1f445361328.zip | |
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.
Diffstat (limited to 'lparser.c')
| -rw-r--r-- | lparser.c | 13 |
1 files changed, 2 insertions, 11 deletions
| @@ -1685,22 +1685,13 @@ static void forbody (LexState *ls, int base, int line, int nvars, int isgen) { | |||
| 1685 | } | 1685 | } |
| 1686 | 1686 | ||
| 1687 | 1687 | ||
| 1688 | /* | ||
| 1689 | ** Control whether for-loop control variables are read-only | ||
| 1690 | */ | ||
| 1691 | #if LUA_COMPAT_LOOPVAR | ||
| 1692 | #define LOOPVARKIND VDKREG | ||
| 1693 | #else /* by default, these variables are read only */ | ||
| 1694 | #define LOOPVARKIND RDKCONST | ||
| 1695 | #endif | ||
| 1696 | |||
| 1697 | static void fornum (LexState *ls, TString *varname, int line) { | 1688 | static void fornum (LexState *ls, TString *varname, int line) { |
| 1698 | /* fornum -> NAME = exp,exp[,exp] forbody */ | 1689 | /* fornum -> NAME = exp,exp[,exp] forbody */ |
| 1699 | FuncState *fs = ls->fs; | 1690 | FuncState *fs = ls->fs; |
| 1700 | int base = fs->freereg; | 1691 | int base = fs->freereg; |
| 1701 | new_localvarliteral(ls, "(for state)"); | 1692 | new_localvarliteral(ls, "(for state)"); |
| 1702 | new_localvarliteral(ls, "(for state)"); | 1693 | new_localvarliteral(ls, "(for state)"); |
| 1703 | new_varkind(ls, varname, LOOPVARKIND); /* control variable */ | 1694 | new_varkind(ls, varname, RDKCONST); /* control variable */ |
| 1704 | checknext(ls, '='); | 1695 | checknext(ls, '='); |
| 1705 | exp1(ls); /* initial value */ | 1696 | exp1(ls); /* initial value */ |
| 1706 | checknext(ls, ','); | 1697 | checknext(ls, ','); |
| @@ -1727,7 +1718,7 @@ static void forlist (LexState *ls, TString *indexname) { | |||
| 1727 | new_localvarliteral(ls, "(for state)"); /* iterator function */ | 1718 | new_localvarliteral(ls, "(for state)"); /* iterator function */ |
| 1728 | new_localvarliteral(ls, "(for state)"); /* state */ | 1719 | new_localvarliteral(ls, "(for state)"); /* state */ |
| 1729 | new_localvarliteral(ls, "(for state)"); /* closing var. (after swap) */ | 1720 | new_localvarliteral(ls, "(for state)"); /* closing var. (after swap) */ |
| 1730 | new_varkind(ls, indexname, LOOPVARKIND); /* control variable */ | 1721 | new_varkind(ls, indexname, RDKCONST); /* control variable */ |
| 1731 | /* other declared variables */ | 1722 | /* other declared variables */ |
| 1732 | while (testnext(ls, ',')) { | 1723 | while (testnext(ls, ',')) { |
| 1733 | new_localvar(ls, str_checkname(ls)); | 1724 | new_localvar(ls, str_checkname(ls)); |
