From 599b44716801aea385e5726a37c788cdf674f78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 28 Jun 2022 15:12:57 +0800 Subject: fix #1242 wrong `sindex` in multi-assign which last exp is `call` or `varargs` --- script/parser/compile.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'script') diff --git a/script/parser/compile.lua b/script/parser/compile.lua index ac599030..83153614 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -2767,11 +2767,15 @@ local function parseMultiVars(n1, parser, isLocal) missExp() end end - bindValue(n1, v1, 1, nil, isLocal, isSet) + local index = 1 + bindValue(n1, v1, index, nil, isLocal, isSet) local lastValue = v1 if n2 then max = 2 - bindValue(n2, v2, 2, lastValue, isLocal, isSet) + if not v2 then + index = 2 + end + bindValue(n2, v2, index, lastValue, isLocal, isSet) lastValue = v2 or lastValue pushActionIntoCurrentChunk(n2) end @@ -2780,7 +2784,10 @@ local function parseMultiVars(n1, parser, isLocal) local n = nrest[i] local v = vrest and vrest[i] max = i + 2 - bindValue(n, v, max, lastValue, isLocal, isSet) + if not v then + index = index + 1 + end + bindValue(n, v, index, lastValue, isLocal, isSet) lastValue = v or lastValue pushActionIntoCurrentChunk(n) end -- cgit v1.2.3