diff options
-rw-r--r-- | changelog.md | 2 | ||||
-rw-r--r-- | script/core/diagnostics/param-type-mismatch.lua | 6 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 13 |
3 files changed, 17 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md index 9dfff867..41a5224b 100644 --- a/changelog.md +++ b/changelog.md @@ -4,10 +4,12 @@ * `FIX` [#1715] * `FIX` [#1753] * `FIX` [#1914] +* `FIX` [#1922] [#1715]: https://github.com/LuaLS/lua-language-server/issues/1715 [#1753]: https://github.com/LuaLS/lua-language-server/issues/1753 [#1914]: https://github.com/LuaLS/lua-language-server/issues/1914 +[#1922]: https://github.com/LuaLS/lua-language-server/issues/1922 ## 3.6.13 `2023-3-2` diff --git a/script/core/diagnostics/param-type-mismatch.lua b/script/core/diagnostics/param-type-mismatch.lua index 607d4b0e..da39c5e1 100644 --- a/script/core/diagnostics/param-type-mismatch.lua +++ b/script/core/diagnostics/param-type-mismatch.lua @@ -87,9 +87,6 @@ return function (uri, callback) await.delay() local funcNode = vm.compileNode(source.node) for i, arg in ipairs(source.args) do - if i == 1 and source.node.type == 'getmethod' then - goto CONTINUE - end local refNode = vm.compileNode(arg) if not refNode then goto CONTINUE @@ -99,7 +96,8 @@ return function (uri, callback) goto CONTINUE end if arg.type == 'getfield' - or arg.type == 'getindex' then + or arg.type == 'getindex' + or arg.type == 'self' then -- 由于无法对字段进行类型收窄, -- 因此将假值移除再进行检查 refNode = refNode:copy():setTruthy() diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 198ead64..568e8985 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -1211,6 +1211,19 @@ end get_val('hi') ]] +TESTWITH 'param-type-mismatch' [[ +---@class Class +local Class = {} + +---@param source string +function Class.staticCreator(source) + +end + +Class.staticCreator(<!true!>) +Class<!:!>staticCreator() -- Expecting a waring +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'unused-function') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') |