summaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-10-28 15:28:40 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-10-28 15:28:40 -0200
commit6707ce63491ad5f233f30b1d561ed7f0f0b9a0c8 (patch)
treebe151820c74eb2ebc4655783a100c96504c107aa /lparser.c
parent257961c601fdec1ea1f9640d460e0d31c39333a1 (diff)
downloadlua-github-6707ce63491ad5f233f30b1d561ed7f0f0b9a0c8.tar.gz
function prepares vararg only if it really uses them (chunks
are always declared vararg but seldom uses them)
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lparser.c b/lparser.c
index d65e8884..e621f680 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.146 2014/11/27 18:41:43 roberto Exp roberto $
+** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -760,7 +760,7 @@ static void parlist (LexState *ls) {
}
case TK_DOTS: { /* param -> '...' */
luaX_next(ls);
- f->is_vararg = 1;
+ f->is_vararg = 2; /* declared vararg */
break;
}
default: luaX_syntaxerror(ls, "<name> or '...' expected");
@@ -956,6 +956,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
FuncState *fs = ls->fs;
check_condition(ls, fs->f->is_vararg,
"cannot use '...' outside a vararg function");
+ fs->f->is_vararg = 1; /* function actually uses vararg */
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
break;
}
@@ -1610,7 +1611,7 @@ static void mainfunc (LexState *ls, FuncState *fs) {
BlockCnt bl;
expdesc v;
open_func(ls, fs, &bl);
- fs->f->is_vararg = 1; /* main function is always vararg */
+ fs->f->is_vararg = 2; /* main function is always declared vararg */
init_exp(&v, VLOCAL, 0); /* create and... */
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
luaX_next(ls); /* read first token */