diff options
-rw-r--r-- | script/vm/infer.lua | 8 | ||||
-rw-r--r-- | test/type_inference/init.lua | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua index 9bcd3963..422990f8 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -20,6 +20,8 @@ mt._isLocal = false vm.NULL = setmetatable({}, mt) +local LOCK = {} + local inferSorted = { ['boolean'] = - 100, ['string'] = - 99, @@ -218,6 +220,10 @@ function mt:_eraseAlias(uri) local expandAlias = config.get(uri, 'Lua.hover.expandAlias') for n in self.node:eachObject() do if n.type == 'global' and n.cate == 'type' then + if LOCK[n.name] then + goto CONTINUE + end + LOCK[n.name] = true for _, set in ipairs(n:getSets(uri)) do if set.type == 'doc.alias' then if expandAlias then @@ -239,6 +245,8 @@ function mt:_eraseAlias(uri) end end end + LOCK[n.name] = nil + ::CONTINUE:: end end return drop diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index efcc5fea..ecc22a3f 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -2491,3 +2491,24 @@ end print(<?x?>) ]] + +TEST 'table<unknown, true>' [[ +---@alias xxx table<xxx, true> + +---@type xxx +local <?t?> +]] + +TEST 'unknown[][]' [[ +---@alias xxx xxx[] + +---@type xxx +local <?t?> +]] + +TEST 'fun(x: fun(x: unknown))' [[ +---@alias xxx fun(x: xxx) + +---@type xxx +local <?t?> +]] |