Skip to content

Commit 2fb6504

Browse files
committed
修正一个bug
1 parent 2b434ab commit 2fb6504

File tree

2 files changed

+28
-36
lines changed

2 files changed

+28
-36
lines changed

script-beta/core/hover/table.lua

+13-36
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,16 @@ local function getField(src, timeUp, mark, key)
8787
return nil
8888
end
8989
if src.parent then
90-
if src.parent.type == 'tableindex'
91-
or src.parent.type == 'setindex'
92-
or src.parent.type == 'getindex' then
93-
if src.parent.index == src then
94-
src = src.parent
90+
if src.type == 'string'
91+
or src.type == 'boolean'
92+
or src.type == 'number'
93+
or src.type == 'integer' then
94+
if src.parent.type == 'tableindex'
95+
or src.parent.type == 'setindex'
96+
or src.parent.type == 'getindex' then
97+
if src.parent.index == src then
98+
src = src.parent
99+
end
95100
end
96101
end
97102
end
@@ -189,37 +194,9 @@ local function mergeTypes(types)
189194
end
190195

191196
local function clearClasses(classes)
192-
local knownClasses = {
193-
['any'] = true,
194-
['nil'] = true,
195-
}
196-
local anyClasses = {}
197-
local strClasses = {}
198-
for key, class in pairs(classes) do
199-
if key == '[any]' then
200-
util.array2hash(class, anyClasses)
201-
goto CONTINUE
202-
elseif key == '[string]' then
203-
util.array2hash(class, strClasses)
204-
goto CONTINUE
205-
end
206-
util.array2hash(class, knownClasses)
207-
::CONTINUE::
208-
end
209-
for c in pairs(knownClasses) do
210-
anyClasses[c] = nil
211-
strClasses[c] = nil
212-
end
213-
if next(anyClasses) then
214-
classes['[any]'] = util.hash2array(anyClasses)
215-
else
216-
classes['[any]'] = nil
217-
end
218-
if next(strClasses) then
219-
classes['[string]'] = util.hash2array(strClasses)
220-
else
221-
classes['[string]'] = nil
222-
end
197+
classes['[nil]'] = nil
198+
classes['[any]'] = nil
199+
classes['[string]'] = nil
223200
end
224201

225202
return function (source)

test-beta/hover/init.lua

+15
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,21 @@ function a(b: table)
866866
-> any
867867
]]
868868

869+
TEST [[
870+
local <?t?> = {
871+
a = true
872+
}
873+
874+
local t2 = {
875+
[t.a] = function () end,
876+
}
877+
]]
878+
[[
879+
local t: {
880+
a: boolean = true,
881+
}
882+
]]
883+
869884
TEST[[
870885
---@class Class
871886
local <?x?> = class()

0 commit comments

Comments
 (0)