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

Gradualizer can't tell that m and f don't exist in erlang:apply(m, f, [some, args]) #561

Open
erszcz opened this issue Mar 19, 2024 · 2 comments

Comments

@erszcz
Copy link
Collaborator

erszcz commented Mar 19, 2024

Reported by @aleklisi on erlanger.slack.com. Here's how to reproduce.

Create a new library:

r3 new lib name=mylib

Within it create the following module:

$ cd mylib
$ cat src/z.erl
-module(z).

f() ->
    erlang:apply(m, f, [1,2,3]).

Add Gradualizer as a Rebar3 plugin and run:

rebar3 gradualizer

Compare with:

rebar3 xref

The latter returns info that m and f don't exist, but Gradualizer doesn't.

@zuiderkwast
Copy link
Collaborator

I don't think we have any magic handling of apply and I'm not sure a type checker should do that. It's rather something for other tools, like xref. Type wise, apply is just a function that takes some atoms and a list. The type module() is just an alias of atom().

@erszcz
Copy link
Collaborator Author

erszcz commented Mar 19, 2024

@zuiderkwast In general I agree, but I wanted to create a ticket to have a discussion around it, since this was raised by a colleague and I think it's worth considering. Given xref detects this, I don't think Gradualizer has to duplicate the functionality, but better have it documented that it's a deliberate choice and not just an omission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants