From f33cc4ddec886ea499d7d41dd60cac5ddc5687db Mon Sep 17 00:00:00 2001 From: Roberto I Date: Wed, 26 Nov 2025 11:18:29 -0300 Subject: New conceptual model for vararg Conceptually, all functions get their vararg arguments in a vararg table. The storing of vararg arguments in the stack is always treated as an optimization. --- lcode.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 95ef900c..afed05d1 100644 --- a/lcode.c +++ b/lcode.c @@ -1951,6 +1951,11 @@ void luaK_finish (FuncState *fs) { SET_OPCODE(*pc, OP_GETTABLE); /* must get vararg there */ break; } + case OP_VARARG: { + if (p->flag & PF_VATAB) /* function has a vararg table? */ + SETARG_k(*pc, 1); /* must get vararg there */ + break; + } case OP_JMP: { /* to optimize jumps to jumps */ int target = finaltarget(p->code, i); fixjump(fs, i, target); /* jump directly to final target */ -- cgit v1.2.3-55-g6feb