erlang_ls icon indicating copy to clipboard operation
erlang_ls copied to clipboard

Usage of ?MODULE in header file function generates compiler error

Open eproxus opened this issue 1 year ago • 0 comments

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

  • erlang_ls version (tag/sha): Version: 0.51.0
  • Editor used: Sublime Text 4 (4168)
  • LSP client used: Sublime LSP v1.28.0

eproxus avatar Feb 14 '24 12:02 eproxus