summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-18 16:54:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-18 16:54:50 +0800
commitf86c80cf43729d09f816c2ae7c13a26d80ed1179 (patch)
treed5c396e14036cf6570198476ab9d08751ce3a673
parent7b3bdcfb3f62695bb8ad237046285634a701a697 (diff)
downloadlua-language-server-f86c80cf43729d09f816c2ae7c13a26d80ed1179.zip
update
-rw-r--r--script/vm/type.lua10
-rw-r--r--test/diagnostics/type-check.lua11
-rw-r--r--test/full/example.lua1
-rw-r--r--test/full/init.lua2
4 files changed, 18 insertions, 6 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua
index d2c5d663..15c94dfc 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -1,5 +1,6 @@
---@class vm
local vm = require 'vm.vm'
+local guide = require 'parser.guide'
---@param object vm.object
---@return string?
@@ -50,11 +51,6 @@ function vm.isSubType(uri, child, parent, mark)
return false
end
end
- if child:isOptional() then
- if not vm.isSubType(uri, 'nil', parent, mark) then
- return false
- end
- end
return true
end
@@ -93,6 +89,10 @@ function vm.isSubType(uri, child, parent, mark)
return true
end
+ if parentName == 'table' and not guide.isBasicType(childName) then
+ return true
+ end
+
-- check class parent
if not mark[child] then
mark[child] = true
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 9de3e061..c8ea17a4 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -159,6 +159,17 @@ local x = 0
<!x!> = 1.0
]]
+TEST [[
+---@class A
+
+local t = {}
+
+---@type A
+local a
+
+t = a
+]]
+
do return end
TEST [[
---@diagnostic disable: unused-local
diff --git a/test/full/example.lua b/test/full/example.lua
index 6afbf2d6..7740d23c 100644
--- a/test/full/example.lua
+++ b/test/full/example.lua
@@ -22,6 +22,7 @@ local function testIfExit(path)
local noderClock = 0
local total
for i = 1, max do
+ ---@type table
state = TEST(buf)
local luadocStart = os.clock()
luadoc(state)
diff --git a/test/full/init.lua b/test/full/init.lua
index 3b1d2fe2..ac78f134 100644
--- a/test/full/init.lua
+++ b/test/full/init.lua
@@ -6,7 +6,7 @@ rawset(_G, 'TEST', true)
function TEST(script)
local clock = os.clock()
- local state = parser.compile(script, 'Lua', 'Lua 5.3')
+ local state = parser.compile(script, 'Lua', 'Lua 5.4')
state.compileClock = os.clock() - clock
return state
end