Skip to content

Commit 90b95a0

Browse files
committed
local uses nil at least
fix #2155
1 parent f5fcab0 commit 90b95a0

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
## 3.7.0
44
* `NEW` support `---@type` and `--[[@as]]` for return statement
55
* `FIX` wrong hover and signature for method with varargs and overloads
6+
* `FIX` [#2155]
67
* `FIX` [#2224]
78

9+
[#2155]: https://github.com/LuaLS/lua-language-server/issues/2155
810
[#2224]: https://github.com/LuaLS/lua-language-server/issues/2224
911

1012
## 3.6.25

script/vm/compiler.lua

+6
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,12 @@ local function compileLocal(source)
11121112
end
11131113
end
11141114

1115+
if source.value
1116+
and source.value.type == 'nil'
1117+
and not myNode:hasKnownType() then
1118+
vm.setNode(source, vm.compileNode(source.value))
1119+
end
1120+
11151121
myNode.hasDefined = hasMarkDoc or hasMarkParam or hasMarkValue
11161122
end
11171123

test/type_inference/init.lua

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ function TEST(wanted)
4444
end
4545
end
4646

47+
TEST 'nil' [[
48+
local <?t?> = nil
49+
]]
50+
4751
TEST 'string' [[
4852
local <?var?> = '111'
4953
]]

0 commit comments

Comments
 (0)