Skip to content

textDocument/definition has incorrect results in some contexts #48

@wu4

Description

@wu4
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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions