From 76c7098956305de4ca0be6f260c10ab8f8c6fa04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 26 Apr 2023 14:11:14 +0800 Subject: [PATCH] lock parsing resume fix #2056 --- changelog.md | 2 ++ script/parser/luadoc.lua | 19 ++++++------------- test/type_inference/init.lua | 10 ++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/changelog.md b/changelog.md index 8676660d3..d0b73673c 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 2f5a8ad35..c022adcbf 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 51de9cd55..12a8e2ab1 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -4268,3 +4268,13 @@ local b = '2'; local = a .. b; ]] + +TEST 'number|{ [1]: string }' [[ +---@alias Some +---| { [1]: string } +---| number + +local x ---@type Some + +print() +]]