Skip to content

Commit 095a670

Browse files
committed
fix #1684
1 parent 9e61b29 commit 095a670

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# changelog
22

3+
## 3.6.3
4+
* `FIX` [#1684]
5+
6+
[#1684]: https://github.com/sumneko/lua-language-server/issues/1684
7+
38
## 3.6.2
49
`2022-11-10`
510
* `FIX` incorrect type check for generic with nil

script/vm/type.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,11 @@ function vm.isSubType(uri, child, parent, mark, errs)
285285
local hasKnownType = 0
286286
for n in child:eachObject() do
287287
if vm.getNodeName(n) then
288-
hasKnownType = hasKnownType + 1
289-
if vm.isSubType(uri, n, parent, mark, errs) == true then
288+
local res = vm.isSubType(uri, n, parent, mark, errs)
289+
if res == true then
290290
return true
291+
elseif res == false then
292+
hasKnownType = hasKnownType + 1
291293
end
292294
end
293295
end
@@ -350,9 +352,11 @@ function vm.isSubType(uri, child, parent, mark, errs)
350352
local hasKnownType = 0
351353
for n in parent:eachObject() do
352354
if vm.getNodeName(n) then
353-
hasKnownType = hasKnownType + 1
354-
if vm.isSubType(uri, child, n, mark, errs) == true then
355+
local res = vm.isSubType(uri, child, n, mark, errs)
356+
if res == true then
355357
return true
358+
elseif res == false then
359+
hasKnownType = hasKnownType + 1
356360
end
357361
end
358362
if n.type == 'doc.generic.name' then

test/diagnostics/type-check.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,16 @@ TEST [[
11191119
local t = {{'a'}}
11201120
]]
11211121

1122+
TEST [[
1123+
local A = "Hello"
1124+
local B = "World"
1125+
1126+
---@alias myLiteralAliases `A` | `B`
1127+
1128+
---@type myLiteralAliases
1129+
local x = A
1130+
]]
1131+
11221132
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
11231133
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
11241134
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')

0 commit comments

Comments
 (0)