summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md2
-rw-r--r--script/parser/luadoc.lua19
-rw-r--r--test/type_inference/init.lua10
3 files changed, 18 insertions, 13 deletions
diff --git a/changelog.md b/changelog.md
index 8676660d..d0b73673 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,11 +4,13 @@
* `FIX` commandline parameter `checklevel` may not work
* `FIX` [#2036]
* `FIX` [#2037]
+* `FIX` [#2056]
* `FIX` [#2077]
* `FIX` [#2081]
[#2036]: https://github.com/LuaLS/lua-language-server/issues/2036
[#2037]: https://github.com/LuaLS/lua-language-server/issues/2037
+[#2056]: https://github.com/LuaLS/lua-language-server/issues/2056
[#2077]: https://github.com/LuaLS/lua-language-server/issues/2077
[#2081]: https://github.com/LuaLS/lua-language-server/issues/2081
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 2f5a8ad3..c022adcb 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -700,6 +700,8 @@ local function parseResume(parent)
return result
end
+local lockResume = false
+
function parseType(parent)
local result = {
type = 'doc.type',
@@ -778,20 +780,10 @@ function parseType(parent)
return false
end
- local checkResume = true
- local nsymbol, ncontent = peekToken()
- if nsymbol == 'symbol' then
- if ncontent == ','
- or ncontent == ':'
- or ncontent == '|'
- or ncontent == ')'
- or ncontent == '}' then
- checkResume = false
- end
- end
-
- if checkResume then
+ if not lockResume then
+ lockResume = true
while pushResume() do end
+ lockResume = false
end
if #result.types == 0 then
@@ -2051,6 +2043,7 @@ return function (state)
if not comment then
break
end
+ lockResume = false
local doc, rests = buildLuaDoc(comment)
if doc then
insertDoc(doc, comment)
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 51de9cd5..12a8e2ab 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -4268,3 +4268,13 @@ local b = '2';
local <?c?> = a .. b;
]]
+
+TEST 'number|{ [1]: string }' [[
+---@alias Some
+---| { [1]: string }
+---| number
+
+local x ---@type Some
+
+print(<?x?>)
+]]