diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-18 12:03:54 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-18 12:03:54 -0300 |
| commit | 6d53701c7a0dc4736d824fd891ee6f22265d0d68 (patch) | |
| tree | 74876c6991b50c0327012e9cb9a3dc282925767d /lparser.c | |
| parent | abbae57c7844b1121e7251d56f681394f20c1821 (diff) | |
| download | lua-6d53701c7a0dc4736d824fd891ee6f22265d0d68.tar.gz lua-6d53701c7a0dc4736d824fd891ee6f22265d0d68.tar.bz2 lua-6d53701c7a0dc4736d824fd891ee6f22265d0d68.zip | |
Proper error message when jumping into 'global *'
A goto cannot jump into the scope of any variable declaration,
including 'global *'. To report the error, it needs a "name" for
the scope it is entering.
Diffstat (limited to 'lparser.c')
| -rw-r--r-- | lparser.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -542,13 +542,13 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { | |||
| 542 | 542 | ||
| 543 | /* | 543 | /* |
| 544 | ** Generates an error that a goto jumps into the scope of some | 544 | ** Generates an error that a goto jumps into the scope of some |
| 545 | ** local variable. | 545 | ** variable declaration. |
| 546 | */ | 546 | */ |
| 547 | static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { | 547 | static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) { |
| 548 | TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name; | 548 | TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name; |
| 549 | const char *varname = getstr(tsname); | 549 | const char *varname = (tsname != NULL) ? getstr(tsname) : "*"; |
| 550 | luaK_semerror(ls, | 550 | luaK_semerror(ls, |
| 551 | "<goto %s> at line %d jumps into the scope of local '%s'", | 551 | "<goto %s> at line %d jumps into the scope of '%s'", |
| 552 | getstr(gt->name), gt->line, varname); /* raise the error */ | 552 | getstr(gt->name), gt->line, varname); /* raise the error */ |
| 553 | } | 553 | } |
| 554 | 554 | ||
