Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module file name mismatch compiler error not exposed #1152

Closed
eproxus opened this issue Dec 3, 2021 · 3 comments · Fixed by #1156
Closed

Module file name mismatch compiler error not exposed #1152

eproxus opened this issue Dec 3, 2021 · 3 comments · Fixed by #1156
Assignees
Labels
bug Something isn't working

Comments

@eproxus
Copy link

eproxus commented Dec 3, 2021

Describe the bug
A module with a name not matching the file name does issue an error.

To Reproduce
Create a module in the file foo.erl:

-module(bar).

Expected behavior
An error similar to the Erlang compilation error should be issued:

$ erlc foo.erl
/path/to/foo.beam: Module name 'bar' does not match file name 'foo'

Actual behavior
No error is visible.

Context

  • erlang_ls version (tag/sha): 0.21.1
  • Editor used: Sublime Text 4 (4122)
  • LSP client used: Sublime LSP v1.14.0
@eproxus eproxus added the bug Something isn't working label Dec 3, 2021
@robertoaloi
Copy link
Member

Interesting, thanks for the report. I never noticed this since Emacs' Erlang mode already prevents that.
The fact that the error is not visible is due to the basic_validation parameter which is passed to compile:file/2. Even the strong_validation doesn't seem to help.

@robertoaloi
Copy link
Member

Confirmed from the code in OTP. The error is only emitted if a binary is saved, which doesn't happen in the case of basic_validation or strong_validation. I guess we can replicate the check from Erlang LS side.

@eproxus
Copy link
Author

eproxus commented Dec 10, 2021

Should this be a "bug" report to OTP, in that the compiler doesn't validate this? I assume it's hard coded somewhere else in the Erlang compiler stack then, because erlc generates the error...

I guess it's not strictly seen as an error, because you can produce beam files with whatever -module(Name) attribute you want, and they only fail when you actually load them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants