erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
626 stars 136 forks source link

Usage of ?MODULE in header file function generates compiler error #1498

Closed eproxus closed 5 months ago

eproxus commented 7 months ago

Describe the bug If ?MODULE is used in a function defined in a header file there will be a compilation error diagnostic when viewing that file, and a warning in any file that includes that file.

To Reproduce Create a foo.erl:

-module(foo).
-include("foo.hrl").

And a foo.hrl:

-export([f/0]).
f() -> ?MODULE.

Which is accepted by Erlang:

1> c(foo).
{ok,foo}
2> foo:f().
foo

Expected behavior erlang_ls does not generate any compiler warnings.

Actual behavior

/path/to/foo.hrl:
    2:1   error   undefined macro 'MODULE' ​Compiler(E1507)

Context