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

False positives in "function M:F/A is not exported" warning #9267

Closed
jcpetruzza opened this issue Jan 7, 2025 · 0 comments · Fixed by #9296
Closed

False positives in "function M:F/A is not exported" warning #9267

jcpetruzza opened this issue Jan 7, 2025 · 0 comments · Fixed by #9296
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@jcpetruzza
Copy link
Contributor

Describe the bug
Using a recent development version of OTP, erlc is emitting warnings when calling functions that don't exist, and some of those are incorrect.

To Reproduce

  • Example 1: On behaviour modules, behaviour_info/1 is not recognized:
$ cat beh.erl
-module(beh).
-export([go/0]).
-callback foo() -> ok.
go() -> ?MODULE:behaviour_info(callbacks).

$ erlc beh.erl
beh.erl:4:10: Warning: function beh:behaviour_info/1 is not exported
%    4| go() -> ?MODULE:behaviour_info(callbacks).
%     |          ^
  • Example 2: Default values in record definitions inside a header file are not recognized if used before being exported:
$ cat blah/blah.erl
-module(blah).
-record(blah_rec, {
    foo = blah:f() :: integer()
}).
-export([f/0, g/0]).
f() -> 42.
g() -> #blah_rec{}.

$ erlc blah.erl
blah/blah.erl:3:11: Warning: function blah:f/0 is not exported
%    3|     foo = blah:f() :: integer()
%     |           ^

This case happens often when blah_rec is defined in a header file that will also be included from other applications.

Expected behavior
No warning should be reported in these examples. In particular, this breaks builds that treat all warnings as errors.

Affected versions
Happens on a recent master: b4af22d

@jcpetruzza jcpetruzza added the bug Issue is reported as a bug label Jan 7, 2025
@jhogberg jhogberg self-assigned this Jan 8, 2025
@jhogberg jhogberg added the team:VM Assigned to OTP team VM label Jan 8, 2025
jhogberg added a commit to jhogberg/otp that referenced this issue Jan 14, 2025
jhogberg added a commit that referenced this issue Jan 17, 2025
…-warning/GH-9267

erl_lint: Fix edge cases in unknown export warnings
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 17, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 21, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 21, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 23, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 24, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 24, 2025
jcpetruzza pushed a commit to jcpetruzza/otp that referenced this issue Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants