summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-05-25 02:17:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-05-25 02:17:13 +0800
commit50688a8001325308c30a8669783f1d0e379b463b (patch)
tree4206bb8792370a6c02f91bf32782cf9645a0b8c0
parentdfab76e01eb592b0cd2625d71a1ef7a859a2aee1 (diff)
downloadlua-language-server-50688a8001325308c30a8669783f1d0e379b463b.zip
fix #1150
-rw-r--r--changelog.md1
-rw-r--r--script/config/config.lua2
-rw-r--r--script/vm/compiler.lua2
-rw-r--r--test/type_inference/init.lua26
4 files changed, 29 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md
index 557e9c66..884d65db 100644
--- a/changelog.md
+++ b/changelog.md
@@ -11,6 +11,7 @@
* `FIX` [#1134](https://github.com/sumneko/lua-language-server/issues/1134)
* `FIX` [#1141](https://github.com/sumneko/lua-language-server/issues/1141)
* `FIX` [#1144](https://github.com/sumneko/lua-language-server/issues/1144)
+* `FIX` [#1150](https://github.com/sumneko/lua-language-server/issues/1150)
## 3.2.3
`2022-5-16`
diff --git a/script/config/config.lua b/script/config/config.lua
index 538b18ab..dc4b9330 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -434,7 +434,7 @@ function m.update(scp, ...)
local news = table.pack(...)
for i = 1, news.n do
- if news[i] then
+ if type(news[i]) == 'table' then
expand(news[i])
end
end
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 6c95b5bd..cd2b602d 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -533,7 +533,7 @@ end
-- 该函数有副作用,会给source绑定node!
local function bindDocs(source)
local isParam = source.parent.type == 'funcargs'
- or source.parent.type == 'in'
+ or (source.parent.type == 'in' and source.finish <= source.parent.keys.finish)
local docs = source.bindDocs
for i = #docs, 1, -1 do
local doc = docs[i]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 947b97b3..5f54cebf 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -2323,3 +2323,29 @@ end
local <?z?> = f()
]]
+
+TEST 'number' [[
+for _ in _ do
+ ---@type number
+ local <?x?>
+end
+]]
+
+TEST 'unknown' [[
+for _ in _ do
+ ---@param x number
+ local <?x?>
+end
+]]
+
+TEST 'unknown' [[
+---@type number
+for <?x?> in _ do
+end
+]]
+
+TEST 'number' [[
+---@param x number
+for <?x?> in _ do
+end
+]]