summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/parser/compile.lua13
-rw-r--r--test/type_inference/init.lua18
3 files changed, 29 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md
index 6f3ec93d..a4b7c2fb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -45,6 +45,7 @@
* `FIX` sometimes workspace diagnostics are not triggered
* `FIX` [#1228](https://github.com/sumneko/lua-language-server/issues/1228)
* `FIX` [#1229](https://github.com/sumneko/lua-language-server/issues/1229)
+* `FIX` [#1242](https://github.com/sumneko/lua-language-server/issues/1242)
## 3.3.1
`2022-6-17`
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
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 4b745c0d..b5814e29 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3149,3 +3149,21 @@ TEST 'A' [[
---@type A
local <?s?> = ''
]]
+
+TEST 'number' [[
+---@return number
+local function f() end
+local x, <?y?> = 1, f()
+]]
+
+TEST 'boolean' [[
+---@return number, boolean
+local function f() end
+local x, y, <?z?> = 1, f()
+]]
+
+TEST 'number' [[
+---@return number, boolean
+local function f() end
+local x, y, <?z?> = 1, 2, f()
+]]