diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-22 16:29:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-22 16:29:18 +0800 |
commit | 09512074acae34fccc60f31a8c84d022e03ddf23 (patch) | |
tree | d431ad47d4688b6b879686a1c4926235ac3afa01 /script/vm | |
parent | e5d692cb0845e5de7988904017440bd4db551bb7 (diff) | |
download | lua-language-server-09512074acae34fccc60f31a8c84d022e03ddf23.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/type.lua | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua index ecca4382..8e8ca96b 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -95,6 +95,19 @@ function vm.isSubType(uri, child, parent, mark) return true end + if parentName == 'integer' and childName == 'number' then + if child.type == 'number' + and child[1] + and not math.tointeger(child[1]) then + return false + end + if child.type == 'global' + and child.cate == 'type' then + return false + end + return true + end + -- TODO: check duck if parentName == 'table' and not guide.isBasicType(childName) then return true @@ -237,14 +250,6 @@ function vm.canCastType(uri, defNode, refNode) return true end end - if vm.isSubType(uri, refNode, 'number') then - -- allow `local x = 0;x = 1.0`, - -- but not allow `local x ---@type integer;x = 1.0` - if defInfer:hasType(uri, 'integer') - and not defNode:hasType 'integer' then - return true - end - end if vm.isSubType(uri, refNode, defNode) then return true end |