Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Literal string `"async"` in LuaDoc types (e.g. `---@field mode "async" | "sync"`) is no longer mis-parsed as the `async fun` prefix [#3402](https://github.com/LuaLS/lua-language-server/issues/3402)
* `FIX` A `.gitignore` line containing only whitespace no longer ignores the entire workspace [#3458](https://github.com/LuaLS/lua-language-server/issues/3458)
* `FIX` `need-check-nil` diagnostic is no longer reported on safe navigation access (e.g. `x?.field`, `f?.()`, `t?.[key]`), since the optional access itself already handles the nil check. Note that a non-safe access chained after a safe one (e.g. `x.upper()?.field`) still reports, because the safe access only protects its own result.

Expand Down
2 changes: 1 addition & 1 deletion script/parser/luadoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ end

local function parseFunction(parent)
local _, content = peekToken()
if content == 'async' then
if checkToken('name', 'async', 1) then
nextToken()
local pos = getStart()
local tp, cont = peekToken()
Expand Down
52 changes: 52 additions & 0 deletions test/parser_test/ast/LuaDoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,58 @@ LuaDoc [[
},
}

LuaDoc [[
---@field mode "async" | "sync"
]]
{
type = "doc",
start = 0,
finish = 10000,
parent = "<IGNORE>",
[1] = {
type = "doc.field",
start = 10,
finish = 31,
range = 31,
parent = "<IGNORE>",
field = {
type = "doc.field.name",
start = 10,
finish = 14,
parent = "<IGNORE>",
[1] = "mode",
},
bindComments = {
},
extends = {
type = "doc.type",
start = 15,
finish = 31,
parent = "<IGNORE>",
firstFinish = 31,
types = {
[1] = {
type = "doc.type.string",
start = 15,
finish = 22,
parent = "<IGNORE>",
[1] = "async",
[2] = "\"",
},
[2] = {
type = "doc.type.string",
start = 25,
finish = 31,
parent = "<IGNORE>",
[1] = "sync",
[2] = "\"",
},
},
},
originalComment = "<IGNORE>",
},
}

LuaDoc [[
---@field private open function|string
]]
Expand Down
Loading