diff options
Diffstat (limited to '')
| -rw-r--r-- | lparser.c | 15 |
1 files changed, 7 insertions, 8 deletions
| @@ -304,11 +304,9 @@ static void check_readonly (LexState *ls, expdesc *e) { | |||
| 304 | varname = up->name; | 304 | varname = up->name; |
| 305 | break; | 305 | break; |
| 306 | } | 306 | } |
| 307 | case VINDEXUP: case VINDEXSTR: case VINDEXED: { | 307 | case VINDEXUP: case VINDEXSTR: case VINDEXED: { /* global variable */ |
| 308 | int vidx = e->u.ind.vidx; | 308 | if (e->u.ind.ro) /* read-only? */ |
| 309 | /* is it a read-only declared global? */ | 309 | varname = tsvalue(&fs->f->k[e->u.ind.keystr]); |
| 310 | if (vidx != -1 && ls->dyd->actvar.arr[vidx].vd.kind == GDKCONST) | ||
| 311 | varname = ls->dyd->actvar.arr[vidx].vd.name; | ||
| 312 | break; | 310 | break; |
| 313 | } | 311 | } |
| 314 | default: | 312 | default: |
| @@ -483,8 +481,6 @@ static void buildvar (LexState *ls, TString *varname, expdesc *var) { | |||
| 483 | if (var->k == VGLOBAL) { /* global name? */ | 481 | if (var->k == VGLOBAL) { /* global name? */ |
| 484 | expdesc key; | 482 | expdesc key; |
| 485 | int info = var->u.info; | 483 | int info = var->u.info; |
| 486 | lua_assert(info == -1 || | ||
| 487 | eqstr(ls->dyd->actvar.arr[info].vd.name, varname)); | ||
| 488 | /* global by default in the scope of a global declaration? */ | 484 | /* global by default in the scope of a global declaration? */ |
| 489 | if (info == -1 && fs->bl->globdec) | 485 | if (info == -1 && fs->bl->globdec) |
| 490 | luaK_semerror(ls, "variable '%s' not declared", getstr(varname)); | 486 | luaK_semerror(ls, "variable '%s' not declared", getstr(varname)); |
| @@ -495,7 +491,10 @@ static void buildvar (LexState *ls, TString *varname, expdesc *var) { | |||
| 495 | luaK_exp2anyregup(fs, var); /* but could be a constant */ | 491 | luaK_exp2anyregup(fs, var); /* but could be a constant */ |
| 496 | codestring(&key, varname); /* key is variable name */ | 492 | codestring(&key, varname); /* key is variable name */ |
| 497 | luaK_indexed(fs, var, &key); /* env[varname] */ | 493 | luaK_indexed(fs, var, &key); /* env[varname] */ |
| 498 | var->u.ind.vidx = cast_short(info); /* mark it as a declared global */ | 494 | if (info != -1 && ls->dyd->actvar.arr[info].vd.kind == GDKCONST) |
| 495 | var->u.ind.ro = 1; /* mark variable as read-only */ | ||
| 496 | else /* anyway must be a global */ | ||
| 497 | lua_assert(info == -1 || ls->dyd->actvar.arr[info].vd.kind == GDKREG); | ||
| 499 | } | 498 | } |
| 500 | } | 499 | } |
| 501 | 500 | ||
