Skip to content

Commit 08638ee

Browse files
committed
some fix
1 parent 5b95074 commit 08638ee

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

script/core/diagnostics/param-type-mismatch.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ return function (uri, callback)
2222
local param = f.args and f.args[i]
2323
if param then
2424
defNode:merge(vm.compileNode(param))
25+
if param[1] == '...' then
26+
defNode:addOptional()
27+
end
2528
end
2629
end
2730
end

script/core/diagnostics/unused-vararg.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ return function (uri, callback)
1515
end
1616

1717
guide.eachSourceType(ast.ast, 'function', function (source)
18+
if #source == 0 then
19+
return
20+
end
1821
local args = source.args
1922
if not args then
2023
return

script/vm/runner.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function mt:_lookInto(action, topNode, outNode)
209209
local topNode1, outNode1 = self:_lookInto(action[1], topNode, outNode)
210210
local topNode2, outNode2 = self:_lookInto(action[2], outNode1, outNode1:copy())
211211
topNode = vm.createNode(topNode1, topNode2)
212-
outNode = outNode2
212+
outNode = outNode2:copy()
213213
elseif action.op.type == '=='
214214
or action.op.type == '~=' then
215215
local exp, checker

test/diagnostics/type-check.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,5 +580,13 @@ function F()
580580
end
581581
]]
582582

583+
TEST [[
584+
---@param ... number
585+
local function f(...)
586+
end
587+
588+
f(nil)
589+
]]
590+
583591
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
584592
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')

test/type_inference/init.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,3 +3184,19 @@ local t = {
31843184
x = n and <?n?>,
31853185
}
31863186
]]
3187+
3188+
TEST 'table' [[
3189+
---@type table?
3190+
local n
3191+
3192+
if not n or not <?n?>.x then
3193+
end
3194+
]]
3195+
3196+
TEST 'table' [[
3197+
---@type table?
3198+
local n
3199+
3200+
if not n or not <?n?>[1] then
3201+
end
3202+
]]

0 commit comments

Comments
 (0)