summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/client.lua2
-rw-r--r--script/config/config.lua4
-rw-r--r--script/vm/type.lua21
3 files changed, 16 insertions, 11 deletions
diff --git a/script/client.lua b/script/client.lua
index 2ce29803..f0f7aa44 100644
--- a/script/client.lua
+++ b/script/client.lua
@@ -112,7 +112,7 @@ end
---@param type message.type
---@param message string
---@param titles string[]
----@param callback fun(action: string, index: integer)
+---@param callback fun(action?: string, index?: integer)
function m.requestMessage(type, message, titles, callback)
proto.notify('window/logMessage', {
type = define.MessageType[type] or 3,
diff --git a/script/config/config.lua b/script/config/config.lua
index f8d9e985..73d21b0b 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -27,7 +27,7 @@ local function update(scp, key, nowValue, rawValue)
raw[key] = rawValue
end
----@param uri uri
+---@param uri? uri
---@param key? string
---@return scope
local function getScope(uri, key)
@@ -70,7 +70,7 @@ function m.setByScope(scp, key, value)
return true
end
----@param uri uri
+---@param uri? uri
---@param key string
---@param value any
function m.set(uri, key, value)
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