mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
better error message for (deprecated) "%global"
This commit is contained in:
parent
ea16ee41a8
commit
6b6bc532a4
11
llex.c
11
llex.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.116 2002/10/23 19:08:13 roberto Exp roberto $
|
** $Id: llex.c,v 1.117 2002/12/04 17:38:31 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -59,15 +59,20 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void luaX_error (LexState *ls, const char *s, const char *token) {
|
void luaX_errorline (LexState *ls, const char *s, const char *token, int line) {
|
||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
char buff[MAXSRC];
|
char buff[MAXSRC];
|
||||||
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
||||||
luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
|
luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, line, s, token);
|
||||||
luaD_throw(L, LUA_ERRSYNTAX);
|
luaD_throw(L, LUA_ERRSYNTAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void luaX_error (LexState *ls, const char *s, const char *token) {
|
||||||
|
luaX_errorline(ls, s, token, ls->linenumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaX_syntaxerror (LexState *ls, const char *msg) {
|
void luaX_syntaxerror (LexState *ls, const char *msg) {
|
||||||
const char *lasttoken;
|
const char *lasttoken;
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
|
3
llex.h
3
llex.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.45 2002/10/08 18:46:08 roberto Exp roberto $
|
** $Id: llex.h,v 1.46 2002/11/22 16:35:20 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -68,6 +68,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
|
|||||||
int luaX_lex (LexState *LS, SemInfo *seminfo);
|
int luaX_lex (LexState *LS, SemInfo *seminfo);
|
||||||
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
|
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
|
||||||
void luaX_syntaxerror (LexState *ls, const char *s);
|
void luaX_syntaxerror (LexState *ls, const char *s);
|
||||||
|
void luaX_errorline (LexState *ls, const char *s, const char *token, int line);
|
||||||
const char *luaX_token2str (LexState *ls, int token);
|
const char *luaX_token2str (LexState *ls, int token);
|
||||||
|
|
||||||
|
|
||||||
|
16
lparser.c
16
lparser.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.205 2003/02/11 10:49:53 roberto Exp roberto $
|
** $Id: lparser.c,v 1.206 2003/02/18 16:02:56 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -240,8 +240,10 @@ static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void singlevar (LexState *ls, expdesc *var, int base) {
|
static TString *singlevar (LexState *ls, expdesc *var, int base) {
|
||||||
singlevaraux(ls->fs, str_checkname(ls), var, base);
|
TString *varname = str_checkname(ls);
|
||||||
|
singlevaraux(ls->fs, varname, var, base);
|
||||||
|
return varname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -645,9 +647,13 @@ static void prefixexp (LexState *ls, expdesc *v) {
|
|||||||
}
|
}
|
||||||
#ifdef LUA_COMPATUPSYNTAX
|
#ifdef LUA_COMPATUPSYNTAX
|
||||||
case '%': { /* for compatibility only */
|
case '%': { /* for compatibility only */
|
||||||
|
TString *varname;
|
||||||
|
int line = ls->linenumber;
|
||||||
next(ls); /* skip `%' */
|
next(ls); /* skip `%' */
|
||||||
singlevar(ls, v, 1);
|
varname = singlevar(ls, v, 1);
|
||||||
check_condition(ls, v->k == VUPVAL, "global upvalues are obsolete");
|
if (v->k != VUPVAL)
|
||||||
|
luaX_errorline(ls, "global upvalues are obsolete",
|
||||||
|
getstr(varname), line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user