diff options
-rw-r--r-- | changelog.md | 6 | ||||
-rw-r--r-- | script/core/hover/table.lua | 2 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 1 | ||||
-rw-r--r-- | script/vm/type.lua | 13 |
4 files changed, 16 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md index f0a43feb..8777103f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,12 @@ # changelog ## 3.4.0 +* `NEW` diagnostics: + * `cast-local-type` + * `assign-type-mismatch` + * `param-type-mismatch` + * `unknown-cast-variable` + * `cast-type-mismatch` * `CHG` infer `nil` as redundant return value ```lua local function f() end diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua index a80051b9..3a2b7c77 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -180,7 +180,7 @@ return function (source) for view in vm.getInfer(source):eachView(uri) do if view == 'string' - or vm.isSubType(uri, view, 'string') then + or (view ~= 'unknown' and view ~= 'any' and vm.isSubType(uri, view, 'string')) then return nil end end diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index c4f40ac4..94be437f 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -69,6 +69,7 @@ Symbol <- ({} { ev = '\v', name = (m.R('az', 'AZ', '09', '\x80\xff') + m.S('_')) * (m.R('az', 'AZ', '__', '09', '\x80\xff') + m.S('_.*-'))^0, Char10 = function (char) + ---@type integer? char = tonumber(char) if not char or char < 0 or char > 255 then return '' diff --git a/script/vm/type.lua b/script/vm/type.lua index 208f21ed..1cbda65d 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -87,7 +87,9 @@ function vm.isSubType(uri, child, parent, mark) local childName = getNodeName(child) local parentName = getNodeName(parent) if childName == 'any' - or parentName == 'any' then + or parentName == 'any' + or childName == 'unknown' + or parentName == 'unknown' then return true end @@ -240,12 +242,13 @@ function vm.canCastType(uri, defNode, refNode) local defInfer = vm.getInfer(defNode) local refInfer = vm.getInfer(refNode) - if defInfer:hasUnknown(uri) - or defInfer:hasAny(uri) then + if defInfer:hasAny(uri) then return true end - if refInfer:hasUnknown(uri) - or refInfer:hasAny(uri) then + if refInfer:hasAny(uri) then + return true + end + if defInfer:view(uri) == 'unknown' then return true end |