diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-22 17:07:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-22 17:07:02 +0800 |
commit | a212b62603f6087bc5a34c4aea45f7cdb0643a8b (patch) | |
tree | 19a1490ed0569bd7a06bc57efc1f5ac138060d34 /script/vm | |
parent | 72effeb8f9d9f3c04d4f5aa4f228dcd1d84f2815 (diff) | |
download | lua-language-server-a212b62603f6087bc5a34c4aea45f7cdb0643a8b.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/function.lua | 2 | ||||
-rw-r--r-- | script/vm/infer.lua | 6 | ||||
-rw-r--r-- | script/vm/type.lua | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/script/vm/function.lua b/script/vm/function.lua index 45f8c0df..2a169bd6 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -117,7 +117,7 @@ function vm.countReturnsOfFunction(func) max = dmax end end - return min, max + return min or 0, max or math.huge end if func.type == 'doc.type.function' then return vm.countList(func.returns) diff --git a/script/vm/infer.lua b/script/vm/infer.lua index f7ff2569..35a2f59f 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -271,6 +271,12 @@ function mt:hasUnknown(uri) end ---@param uri uri +function mt:hasAny(uri) + self:_computeViews(uri) + return self.views['any'] == true +end + +---@param uri uri ---@return boolean function mt:hasClass(uri) self:_computeViews(uri) diff --git a/script/vm/type.lua b/script/vm/type.lua index 5735b482..fa78f735 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -235,10 +235,12 @@ function vm.canCastType(uri, defNode, refNode) local defInfer = vm.getInfer(defNode) local refInfer = vm.getInfer(refNode) - if defInfer:hasUnknown(uri) then + if defInfer:hasUnknown(uri) + or defInfer:hasAny(uri) then return true end - if refInfer:hasUnknown(uri) then + if refInfer:hasUnknown(uri) + or refInfer:hasAny(uri) then return true end |