diff options
-rw-r--r-- | script-beta/parser/guide.lua | 35 | ||||
-rw-r--r-- | test-beta/type_inference/init.lua | 2 |
2 files changed, 27 insertions, 10 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 925ee9ab..06e6949c 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -3725,18 +3725,35 @@ function m.inferByPCallReturn(status, source) end function m.cleanInfers(infers) - local mark = {} + local hasDoc for i = 1, #infers do local infer = infers[i] - if not infer then - return + if infer.source.type == 'doc.class' + or infer.source.type == 'doc.type.name' then + hasDoc = true end - local key = ('%s|%p'):format(infer.type, infer.source) - if mark[key] then - infers[i] = infers[#infers] - infers[#infers] = nil - else - mark[key] = true + end + if hasDoc then + for i = #infers, 1, -1 do + local infer = infers[i] + if infer.source.type == 'doc.class' + or infer.source.type == 'doc.type.name' then + else + infers[i] = infers[#infers] + infers[#infers] = nil + end + end + else + local mark = {} + for i = #infers, 1, -1 do + local infer = infers[i] + local key = ('%s|%p'):format(infer.type, infer.source) + if mark[key] then + infers[i] = infers[#infers] + infers[#infers] = nil + else + mark[key] = true + end end end end diff --git a/test-beta/type_inference/init.lua b/test-beta/type_inference/init.lua index 4998ee79..edbe0fe2 100644 --- a/test-beta/type_inference/init.lua +++ b/test-beta/type_inference/init.lua @@ -200,7 +200,7 @@ end _, <?y?> = pcall(x) ]] -TEST 'table' [[ +TEST 'os' [[ local <?os?> = require 'os' ]] |