diff options
Diffstat (limited to '')
| -rw-r--r-- | lparser.c | 30 |
1 files changed, 12 insertions, 18 deletions
| @@ -306,11 +306,9 @@ static void check_readonly (LexState *ls, expdesc *e) { | |||
| 306 | default: | 306 | default: |
| 307 | return; /* other cases cannot be read-only */ | 307 | return; /* other cases cannot be read-only */ |
| 308 | } | 308 | } |
| 309 | if (varname) { | 309 | if (varname) |
| 310 | const char *msg = luaO_pushfstring(ls->L, | 310 | luaK_semerror(ls, "attempt to assign to const variable '%s'", |
| 311 | "attempt to assign to const variable '%s'", getstr(varname)); | 311 | getstr(varname)); |
| 312 | luaK_semerror(ls, msg); /* error */ | ||
| 313 | } | ||
| 314 | } | 312 | } |
| 315 | 313 | ||
| 316 | 314 | ||
| @@ -523,9 +521,9 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { | |||
| 523 | static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { | 521 | static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { |
| 524 | TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name; | 522 | TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name; |
| 525 | const char *varname = getstr(tsname); | 523 | const char *varname = getstr(tsname); |
| 526 | const char *msg = "<goto %s> at line %d jumps into the scope of local '%s'"; | 524 | luaK_semerror(ls, |
| 527 | msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname); | 525 | "<goto %s> at line %d jumps into the scope of local '%s'", |
| 528 | luaK_semerror(ls, msg); /* raise the error */ | 526 | getstr(gt->name), gt->line, varname); /* raise the error */ |
| 529 | } | 527 | } |
| 530 | 528 | ||
| 531 | 529 | ||
| @@ -677,11 +675,10 @@ static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { | |||
| 677 | ** generates an error for an undefined 'goto'. | 675 | ** generates an error for an undefined 'goto'. |
| 678 | */ | 676 | */ |
| 679 | static l_noret undefgoto (LexState *ls, Labeldesc *gt) { | 677 | static l_noret undefgoto (LexState *ls, Labeldesc *gt) { |
| 680 | const char *msg = "no visible label '%s' for <goto> at line %d"; | ||
| 681 | msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); | ||
| 682 | /* breaks are checked when created, cannot be undefined */ | 678 | /* breaks are checked when created, cannot be undefined */ |
| 683 | lua_assert(!eqstr(gt->name, luaS_newliteral(ls->L, "break"))); | 679 | lua_assert(!eqstr(gt->name, luaS_newliteral(ls->L, "break"))); |
| 684 | luaK_semerror(ls, msg); | 680 | luaK_semerror(ls, "no visible label '%s' for <goto> at line %d", |
| 681 | getstr(gt->name), gt->line); | ||
| 685 | } | 682 | } |
| 686 | 683 | ||
| 687 | 684 | ||
| @@ -1479,11 +1476,9 @@ static void breakstat (LexState *ls, int line) { | |||
| 1479 | */ | 1476 | */ |
| 1480 | static void checkrepeated (LexState *ls, TString *name) { | 1477 | static void checkrepeated (LexState *ls, TString *name) { |
| 1481 | Labeldesc *lb = findlabel(ls, name, ls->fs->firstlabel); | 1478 | Labeldesc *lb = findlabel(ls, name, ls->fs->firstlabel); |
| 1482 | if (l_unlikely(lb != NULL)) { /* already defined? */ | 1479 | if (l_unlikely(lb != NULL)) /* already defined? */ |
| 1483 | const char *msg = "label '%s' already defined on line %d"; | 1480 | luaK_semerror(ls, "label '%s' already defined on line %d", |
| 1484 | msg = luaO_pushfstring(ls->L, msg, getstr(name), lb->line); | 1481 | getstr(name), lb->line); /* error */ |
| 1485 | luaK_semerror(ls, msg); /* error */ | ||
| 1486 | } | ||
| 1487 | } | 1482 | } |
| 1488 | 1483 | ||
| 1489 | 1484 | ||
| @@ -1718,8 +1713,7 @@ static lu_byte getlocalattribute (LexState *ls) { | |||
| 1718 | else if (strcmp(attr, "close") == 0) | 1713 | else if (strcmp(attr, "close") == 0) |
| 1719 | return RDKTOCLOSE; /* to-be-closed variable */ | 1714 | return RDKTOCLOSE; /* to-be-closed variable */ |
| 1720 | else | 1715 | else |
| 1721 | luaK_semerror(ls, | 1716 | luaK_semerror(ls, "unknown attribute '%s'", attr); |
| 1722 | luaO_pushfstring(ls->L, "unknown attribute '%s'", attr)); | ||
| 1723 | } | 1717 | } |
| 1724 | return VDKREG; /* regular variable */ | 1718 | return VDKREG; /* regular variable */ |
| 1725 | } | 1719 | } |
