aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-17 14:58:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-17 14:58:55 -0300
commit50fd8d03c33bbe52ac5b34c4eb748197b349cedd (patch)
treeef63c627346c7609fea578cd9d8399ae500c00b2 /lparser.c
parent3dbb1a4b894c0744a331d4319d8d1704dc4ad943 (diff)
downloadlua-50fd8d03c33bbe52ac5b34c4eb748197b349cedd.tar.gz
lua-50fd8d03c33bbe52ac5b34c4eb748197b349cedd.tar.bz2
lua-50fd8d03c33bbe52ac5b34c4eb748197b349cedd.zip
Function 'luaK_semerror' made vararg
All calls to 'luaK_semerror' were using 'luaO_pushfstring' to create the error messages.
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/lparser.c b/lparser.c
index 380e45f5..e71d7212 100644
--- a/lparser.c
+++ b/lparser.c
@@ -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) {
523static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { 521static 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*/
679static l_noret undefgoto (LexState *ls, Labeldesc *gt) { 677static 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*/
1480static void checkrepeated (LexState *ls, TString *name) { 1477static 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}