You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Luau Language Server (johnymorgan) with VSCode, I cannot use the "Go to Declaration" functionality for functions defined on tables with metatables and type annotations. This occurs in cases where functions are defined for a table using a type that employs setmetatable for object-like behavior.
Reproduction
Here’s an example:
type AccountImpl = {
__index: AccountImpl,
new: (name: string, balance: number) -> AccountType,
deposit: (self: AccountType, credit: number) -> (),
withdraw: (self: AccountType, debit: number) -> (),
}
type AccountType = typeof(setmetatable({} :: { name: string, balance: number }, {} :: AccountImpl))
local MyAccount: AccountImpl = {} :: AccountImpl
MyAccount.__index = MyAccount
function MyAccount.new(name: string, balance: number): AccountType
local self = {}
self.name = name
self.balance = balance
return setmetatable(self, MyAccount)
end
function MyAccount:deposit(credit: number)
self.balance += credit
end
function MyAccount:withdraw(debit: number)
self.balance -= debit
end
local account = MyAccount.new("Alexander", 500)
account:withdraw(100) -- cannot go to declaration
Expected Behavior
When right-clicking account:withdraw(100) or MyAccount.new(...) and selecting "Go to Declaration," the LSP should navigate to the respective function definitions (MyAccount:withdraw or MyAccount.new).
Observed Behavior
"Go to Declaration" does not work for either the method (withdraw) or the function (new).
Additional Information
Luau Language Server version: 1.32.4
VSCode version: 1.93.1
Reproduction environment: Window
P/S
I have tried adding explicit type annotations, but the issue persists.
If I use Nightrains's Roblox-LSP then the issue no longer persist
Update
I also cannot find "references" & "go to definitions".
So basically I cannot find "references" or "go to definition" if tables assigned to any custom type
The code below is working
local Sample = {}
Sample.__index = Sample
function Sample.HelloWorld(): ()
print("LOL")
end
Sample.HelloWorld() -- Can go to the definition
return Sample
While the other is not
local Sample = {} :: ACustomType
Sample.__index = Sample
function Sample.HelloWorld(): ()
print("LOL")
end
Sample.HelloWorld() -- Can't go to the definition
return Sample
The text was updated successfully, but these errors were encountered:
Problem
When using the Luau Language Server (johnymorgan) with VSCode, I cannot use the "Go to Declaration" functionality for functions defined on tables with metatables and type annotations. This occurs in cases where functions are defined for a table using a type that employs setmetatable for object-like behavior.
Reproduction
Here’s an example:
Expected Behavior
When right-clicking
account:withdraw(100)
orMyAccount.new(...)
and selecting "Go to Declaration," the LSP should navigate to the respective function definitions (MyAccount:withdraw
orMyAccount.new
).Observed Behavior
"Go to Declaration" does not work for either the method (withdraw) or the function (new).
Additional Information
Luau Language Server version: 1.32.4
VSCode version: 1.93.1
Reproduction environment: Window
P/S
Update
Update #2
So basically I cannot find "references" or "go to definition" if tables assigned to any custom type
The code below is working
While the other is not
The text was updated successfully, but these errors were encountered: