Skip to content

Commit 76c7098

Browse files
committed
lock parsing resume
fix #2056
1 parent 881e16b commit 76c7098

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
* `FIX` commandline parameter `checklevel` may not work
55
* `FIX` [#2036]
66
* `FIX` [#2037]
7+
* `FIX` [#2056]
78
* `FIX` [#2077]
89
* `FIX` [#2081]
910

1011
[#2036]: https://github.com/LuaLS/lua-language-server/issues/2036
1112
[#2037]: https://github.com/LuaLS/lua-language-server/issues/2037
13+
[#2056]: https://github.com/LuaLS/lua-language-server/issues/2056
1214
[#2077]: https://github.com/LuaLS/lua-language-server/issues/2077
1315
[#2081]: https://github.com/LuaLS/lua-language-server/issues/2081
1416

script/parser/luadoc.lua

+6-13
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ local function parseResume(parent)
700700
return result
701701
end
702702

703+
local lockResume = false
704+
703705
function parseType(parent)
704706
local result = {
705707
type = 'doc.type',
@@ -778,20 +780,10 @@ function parseType(parent)
778780
return false
779781
end
780782

781-
local checkResume = true
782-
local nsymbol, ncontent = peekToken()
783-
if nsymbol == 'symbol' then
784-
if ncontent == ','
785-
or ncontent == ':'
786-
or ncontent == '|'
787-
or ncontent == ')'
788-
or ncontent == '}' then
789-
checkResume = false
790-
end
791-
end
792-
793-
if checkResume then
783+
if not lockResume then
784+
lockResume = true
794785
while pushResume() do end
786+
lockResume = false
795787
end
796788

797789
if #result.types == 0 then
@@ -2051,6 +2043,7 @@ return function (state)
20512043
if not comment then
20522044
break
20532045
end
2046+
lockResume = false
20542047
local doc, rests = buildLuaDoc(comment)
20552048
if doc then
20562049
insertDoc(doc, comment)

test/type_inference/init.lua

+10
Original file line numberDiff line numberDiff line change
@@ -4268,3 +4268,13 @@ local b = '2';
42684268
42694269
local <?c?> = a .. b;
42704270
]]
4271+
4272+
TEST 'number|{ [1]: string }' [[
4273+
---@alias Some
4274+
---| { [1]: string }
4275+
---| number
4276+
4277+
local x ---@type Some
4278+
4279+
print(<?x?>)
4280+
]]

0 commit comments

Comments
 (0)