Skip to content

Commit

Permalink
local uses nil at least
Browse files Browse the repository at this point in the history
fix #2155
  • Loading branch information
sumneko committed Aug 11, 2023
1 parent f5fcab0 commit 90b95a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions script/vm/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions test/type_inference/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function TEST(wanted)
end
end

TEST 'nil' [[
local <?t?> = nil
]]

TEST 'string' [[
local <?var?> = '111'
]]
Expand Down

0 comments on commit 90b95a0

Please sign in to comment.