summaryrefslogtreecommitdiff
path: root/script/vm/type.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm/type.lua')
-rw-r--r--script/vm/type.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua
index 8e8ca96b..5735b482 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -250,6 +250,16 @@ 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