Gradualizer icon indicating copy to clipboard operation
Gradualizer copied to clipboard

No error when generic function applied to generic function

Open mheiber opened this issue 4 years ago • 2 comments

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.

mheiber avatar Feb 23 '21 21:02 mheiber

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.

zuiderkwast avatar Feb 24 '21 09:02 zuiderkwast

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.

josefs avatar Feb 28 '21 18:02 josefs