Skip to content

Commit

Permalink
fix #1902
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Feb 13, 2023
1 parent 457931e commit 48a608d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
* `FIX` [#1887]
* `FIX` [#1889]
* `FIX` [#1895]
* `FIX` [#1902]

[#1886]: https://github.com/LuaLS/lua-language-server/issues/1886
[#1887]: https://github.com/LuaLS/lua-language-server/issues/1887
[#1889]: https://github.com/LuaLS/lua-language-server/issues/1889
[#1895]: https://github.com/LuaLS/lua-language-server/issues/1895
[#1902]: https://github.com/LuaLS/lua-language-server/issues/1902

## 3.6.10
`2023-2-7`
Expand Down
3 changes: 2 additions & 1 deletion script/vm/tracer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ local lookIntoChild = util.switch()
and handler.args[1]
and tracer.getMap[handler.args[1]] then
-- if type(x) == 'string' then
tracer:lookIntoChild(handler, topNode:copy())
tracer:lookIntoChild(handler, topNode)
topNode = topNode:copy()
if action.op.type == '==' then
topNode:narrow(tracer.uri, checker[1])
if outNode then
Expand Down
10 changes: 10 additions & 0 deletions test/diagnostics/type-check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,16 @@ local function some_fn(some_param) return end
some_fn { { "test" } } -- <- diagnostic: "Cannot assign `table` to `string`."
]]

TEST [[
---@param p integer|string
local function get_val(p)
local is_number = type(p) == 'number'
return is_number and p or p
end
get_val('hi')
]]

config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')
Expand Down

0 comments on commit 48a608d

Please sign in to comment.