summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-11 18:24:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-11 18:24:34 +0800
commit90b95a06eb43b469f53c147509a4d67e1c567fb5 (patch)
treeb20d2a57c13e41c6e7afd09a9043ede1ee787411
parentf5fcab05b5a30373d1b35689d456090c8299c4c2 (diff)
downloadlua-language-server-90b95a06eb43b469f53c147509a4d67e1c567fb5.zip
local uses `nil` at least
fix #2155
-rw-r--r--changelog.md2
-rw-r--r--script/vm/compiler.lua6
-rw-r--r--test/type_inference/init.lua4
3 files changed, 12 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 8cbfc1d2..a39f505d 100644
--- a/changelog.md
+++ b/changelog.md
@@ -3,8 +3,10 @@
## 3.7.0
* `NEW` support `---@type` and `--[[@as]]` for return statement
* `FIX` wrong hover and signature for method with varargs and overloads
+* `FIX` [#2155]
* `FIX` [#2224]
+[#2155]: https://github.com/LuaLS/lua-language-server/issues/2155
[#2224]: https://github.com/LuaLS/lua-language-server/issues/2224
## 3.6.25
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 7faa4f47..7d10561e 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1112,6 +1112,12 @@ local function compileLocal(source)
end
end
+ if source.value
+ and source.value.type == 'nil'
+ and not myNode:hasKnownType() then
+ vm.setNode(source, vm.compileNode(source.value))
+ end
+
myNode.hasDefined = hasMarkDoc or hasMarkParam or hasMarkValue
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index aba6b0b4..98a07ca3 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -44,6 +44,10 @@ function TEST(wanted)
end
end
+TEST 'nil' [[
+local <?t?> = nil
+]]
+
TEST 'string' [[
local <?var?> = '111'
]]