summaryrefslogtreecommitdiff
path: root/script/parser/compile.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-11 15:57:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-11 15:57:46 +0800
commit492ed7f90f8fe575c64d4689b2963bd0674da0f9 (patch)
tree5ee922f1833cd3c8012651348b9c38c7e36c2c70 /script/parser/compile.lua
parentdb71c1ef928c42d0fe8ffbd828cad75908a0f521 (diff)
downloadlua-language-server-492ed7f90f8fe575c64d4689b2963bd0674da0f9.zip
fix #1317
Diffstat (limited to 'script/parser/compile.lua')
-rw-r--r--script/parser/compile.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 1e4165ff..bae1e21a 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -12,11 +12,9 @@ local uchar = utf8.char
local tconcat = table.concat
local tinsert = table.insert
local tointeger = math.tointeger
-local mtype = math.type
local tonumber = tonumber
local maxinteger = math.maxinteger
local assert = assert
-local next = next
_ENV = nil
@@ -2669,7 +2667,6 @@ local function parseVarTails(parser, isLocal)
end
if isLocal then
createLocal(second, parseLocalAttrs())
- second.effect = maxinteger
end
skipSpace()
if Tokens[Index + 1] ~= ',' then
@@ -2684,7 +2681,6 @@ local function parseVarTails(parser, isLocal)
end
if isLocal then
createLocal(third, parseLocalAttrs())
- third.effect = maxinteger
end
local rest = { third }
while true do
@@ -2701,7 +2697,6 @@ local function parseVarTails(parser, isLocal)
end
if isLocal then
createLocal(name, parseLocalAttrs())
- name.effect = maxinteger
end
rest[#rest+1] = name
end
@@ -2709,7 +2704,6 @@ end
local function bindValue(n, v, index, lastValue, isLocal, isSet)
if isLocal then
- n.effect = lastRightPosition()
if v and v.special then
addSpecial(v.special, n)
end
@@ -2755,9 +2749,6 @@ local function bindValue(n, v, index, lastValue, isLocal, isSet)
n.value = v
n.range = v.finish
v.parent = n
- if isLocal then
- n.effect = lastRightPosition()
- end
end
end
@@ -2777,6 +2768,7 @@ local function parseMultiVars(n1, parser, isLocal)
local index = 1
bindValue(n1, v1, index, nil, isLocal, isSet)
local lastValue = v1
+ local lastVar = n1
if n2 then
max = 2
if not v2 then
@@ -2784,6 +2776,7 @@ local function parseMultiVars(n1, parser, isLocal)
end
bindValue(n2, v2, index, lastValue, isLocal, isSet)
lastValue = v2 or lastValue
+ lastVar = n2
pushActionIntoCurrentChunk(n2)
end
if nrest then
@@ -2796,10 +2789,24 @@ local function parseMultiVars(n1, parser, isLocal)
end
bindValue(n, v, index, lastValue, isLocal, isSet)
lastValue = v or lastValue
+ lastVar = n
pushActionIntoCurrentChunk(n)
end
end
+ if isLocal then
+ local effect = lastValue and lastValue.finish or lastVar.finish
+ n1.effect = effect
+ if n2 then
+ n2.effect = effect
+ end
+ if nrest then
+ for i = 1, #nrest do
+ nrest[i].effect = effect
+ end
+ end
+ end
+
if v2 and not n2 then
v2.redundant = {
max = max,
@@ -2921,11 +2928,6 @@ local function parseLocal()
pushActionIntoCurrentChunk(loc)
skipSpace()
parseMultiVars(loc, parseName, true)
- if loc.value then
- loc.effect = loc.value.finish
- else
- loc.effect = loc.finish
- end
return loc
end