teal-language-server
teal-language-server copied to clipboard
textDocument/definition has incorrect results in some contexts
local record TestType
test_value: boolean
metamethod __call: function(self: TestType): boolean
end
local TestType_mt: metatable<TestType>
--[[
trying textDocument/definition on `TestType_mt` attempts to go to the definition for `metatable` in stdlib.d.tl
- should always go to `local TestType_mt`
]]
TestType_mt = {
__call = function(self: TestType): boolean
--[[
trying textDocument/definition on `self` fails (No LSP Definitions found)
- should go to `self` in the function parameters
trying textDocument/definition on `test_value` fails (No LSP Definitions found)
- should go to `test_value` within `local record TestType`
]]
return self.test_value
end
}
--[[
trying textDocument/definition on `a` goes to `local record TestType`
- should go to itself as this is the definition
trying textDocument/definition on `test_value` fails (No LSP Definitions found)
- should either go to itself or to `test_value` within `local record TestType`
]]
local a: TestType = setmetatable({test_value = true}, TestType_mt)
--[[
trying textDocument/definition on `a` goes to `local record TestType`
- should probably go to __call in the metatable, but could also reasonably go to `local a`
]]
a()
Yeah, I'm able to replicate, this is some odd behaviour. Thanks for reporting!