Skip to content

Commit 1b3a03e

Browse files
committed
支持多个enum合并
1 parent 720c398 commit 1b3a03e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

script/vm/type.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ local function checkParentEnum(parentName, child, uri, mark, errs)
6565
local enums
6666
for _, set in ipairs(parentClass:getSets(uri)) do
6767
if set.type == 'doc.enum' then
68-
enums = vm.getEnums(set)
69-
break
68+
local denums = vm.getEnums(set)
69+
if denums then
70+
if enums then
71+
enums = util.arrayMerge(enums, denums)
72+
else
73+
enums = denums
74+
end
75+
end
7076
end
7177
end
7278
if not enums then

test/diagnostics/param-type-mismatch.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,21 @@ local MyClass = {}
246246
247247
local w = MyClass(<!1!>)
248248
]]
249+
250+
TEST [[
251+
---@enum(key) A
252+
local t1 = {
253+
x = 1,
254+
}
255+
256+
---@enum(key) A
257+
local t2 = {
258+
y = 1,
259+
}
260+
261+
---@param v A
262+
local function f(v) end
263+
264+
f 'x'
265+
f 'y'
266+
]]

0 commit comments

Comments
 (0)