Skip to content

GOTO definition not working for some macros #1052

Closed
@DonDi94

Description

Describe the bug
There are some corner cases in which the goto definition does not work for some macros:

  • if ?MODULE is used as record name
  • if a macro is used to define a case clause

To Reproduce
To reproduce, create two files:

test.erl

-module(test).
-export([test_function/0, test_function_2/0]).
-include("export.hrl").

-define(macro, 1).

-record(?MODULE, {
    test :: #test_record{} %% GOTO Def Works
}).

-define(CASE(A, B), 
    V when V == A -> B).

test_function() -> 
    #?MODULE{}, %% GOTO Def Doesn't work
    ?macro, %% GOTO Def Works
    #test_record{}, %% GOTO Def Works
    ok. 

test_function_2() ->
    ?macro, %% GOTO Def doesn't work
    case 4 of
        ?CASE(4,5); %% GOTO Def doesn't work
        _ -> 3
    end.

and export.hrl

-record(test_record, {value}).

Expected behavior
GOTO definition should bring the cursor to the macro definitions.

Actual behavior

  • Using GOTO Def on ?MODULE does not work at all
  • If a case clause is defined with a macro like ?CASE(4,5), GOTO Def will not work anywhere in the function where ?CASE(4,5) is used

Context

  • erlang_ls version (tag/sha): 0.0.27
  • Editor used: VS Code
  • LSP client used: VS Code integrated LSP

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions