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.
This commit is contained in:
@@ -542,13 +542,13 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
|
||||
|
||||
/*
|
||||
** Generates an error that a goto jumps into the scope of some
|
||||
** local variable.
|
||||
** variable declaration.
|
||||
*/
|
||||
static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
|
||||
TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name;
|
||||
const char *varname = getstr(tsname);
|
||||
const char *varname = (tsname != NULL) ? getstr(tsname) : "*";
|
||||
luaK_semerror(ls,
|
||||
"<goto %s> at line %d jumps into the scope of local '%s'",
|
||||
"<goto %s> at line %d jumps into the scope of '%s'",
|
||||
getstr(gt->name), gt->line, varname); /* raise the error */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user