Gradualizer
Gradualizer copied to clipboard
No error when generic function applied to generic function
Example:
-module(sample).
-export([test/1]).
-spec test(atom()) -> pid().
test(X) -> fapply(fun idz/1, X).
-spec idz(Z) -> Z.
idz(Z) -> Z.
-spec fapply(fun((T) -> U), T) -> U.
fapply(F, X) ->
ZZ = F(X),
ZZ.
command: ./bin/gradaulizer sample.erl
Expected behavior:
- Error message like: "The variable on line _ at column _ is expected to have type pid() but it has type atom()"
- Nonzero return code.
Actual behavior:
- No error message
- Return code is zero.
This is low priority: I'm looking into this for my own learning and am not blocked by this issue. Thanks for your help.
The example relies on type variables. Perhaps you may want to try this in the constraint-solver branch. I don't know the status of that branch (maybe @josefs knows), but constraint solving is the step that unifies the type variables to find the kind of mismatches you have in your example.
Thanks for the excellent bug report!
Currently the constraint-solver branch doesn't help with this example. Most of the important pieces are in place but they need to be put together correctly. See #284 for details.