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` Generic aliases of async functions (e.g. `---@alias Name<T> async fun(): T` used as `Name<string>`) keep the `async` flag, so `await-in-sync` and hover treat them as async [#3469](https://github.com/LuaLS/lua-language-server/issues/3469)

## 3.19.2
`2026-10-13`
Expand Down
2 changes: 2 additions & 0 deletions script/vm/generic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ local function cloneObject(source, resolved)
start = source.start,
finish = source.finish,
parent = source.parent,
async = source.async,
asyncPos = source.asyncPos,
args = {},
returns = {},
}
Expand Down
50 changes: 50 additions & 0 deletions test/diagnostics/await-in-sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,53 @@ end

return af
]]

TEST [[
---@alias AsyncGenericFunc<T> async fun(): T

---@type AsyncGenericFunc<string>
local f

function F()
<!f!>()
end
]]

TEST [[
---@alias AsyncGenericFunc<T> async fun(x: T)

---@type AsyncGenericFunc<integer>
local f

---@async
function F()
f(1)
end
]]

TEST [[
---@alias AsyncGenericFunc<T> async fun(): T

---@class AsyncGenericHolder
---@field run AsyncGenericFunc<string>

---@type AsyncGenericHolder
local holder

function F()
<!holder.run!>()
end
]]

TEST [[
---@alias AsyncGenericFunc<T> async fun(): T

---@type AsyncGenericFunc<string>
local function f()
return 'x'
end

function F()
<!f!>()
end
]]
10 changes: 10 additions & 0 deletions test/hover/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,16 @@ local <?f?>
local f: async fun()
]]

TEST [[
---@alias AsyncGenericFunc<T> async fun(): T

---@type AsyncGenericFunc<string>
local <?f?>
]]
[[
local f: async AsyncGenericFunc<string>
]]

config.set(nil, 'Lua.runtime.nonstandardSymbol', { '//' })
TEST [[
local <?x?> = 1 // 2
Expand Down
Loading