diff options
| -rw-r--r-- | lcode.c | 4 | ||||
| -rw-r--r-- | testes/vararg.lua | 12 |
2 files changed, 16 insertions, 0 deletions
| @@ -1109,6 +1109,10 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { | |||
| 1109 | codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); | 1109 | codeABRK(fs, OP_SETFIELD, var->u.ind.t, var->u.ind.idx, ex); |
| 1110 | break; | 1110 | break; |
| 1111 | } | 1111 | } |
| 1112 | case VVARGIND: { | ||
| 1113 | fs->f->flag |= PF_VATAB; /* function will need a vararg table */ | ||
| 1114 | /* now, assignment is to a regular table */ | ||
| 1115 | } /* FALLTHROUGH */ | ||
| 1112 | case VINDEXED: { | 1116 | case VINDEXED: { |
| 1113 | codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); | 1117 | codeABRK(fs, OP_SETTABLE, var->u.ind.t, var->u.ind.idx, ex); |
| 1114 | break; | 1118 | break; |
diff --git a/testes/vararg.lua b/testes/vararg.lua index 5711f78b..840c3eee 100644 --- a/testes/vararg.lua +++ b/testes/vararg.lua | |||
| @@ -184,6 +184,18 @@ do -- _ENV as vararg parameter | |||
| 184 | a = 10 | 184 | a = 10 |
| 185 | end ]] | 185 | end ]] |
| 186 | assert(string.find(msg, "const variable 'a'")) | 186 | assert(string.find(msg, "const variable 'a'")) |
| 187 | |||
| 188 | local function aux (... | _ENV) | ||
| 189 | global a; a = 10 | ||
| 190 | return a | ||
| 191 | end | ||
| 192 | assert(aux() == 10) | ||
| 193 | |||
| 194 | local function aux (... | _ENV) | ||
| 195 | global a = 10 | ||
| 196 | return a | ||
| 197 | end | ||
| 198 | assert(aux() == 10) | ||
| 187 | end | 199 | end |
| 188 | 200 | ||
| 189 | 201 | ||
