-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
Description
The following code is correctly rejected by Gradualizer:
-spec poly_2(fun((A) -> A)) -> {integer(), boolean()}.
poly_2(F) -> {F(42), F(false)}.However, the following code is not rejected:
-spec poly_2(fun((A) -> A)) -> {integer(), integer()}.
poly_2(F) -> {F(42), F(84)}.while by itself it seems harmless. We could argue whether the above code is valid or not based on polymorphism rank we'd like to support (rank-1 - invalid, rank-2 - valid). However, an invalid application like the following should be rejected in any case, whereas it's not:
-gradualizer([solve_constraints]).
-spec poly_2(fun((A) -> A)) -> {integer(), integer()}.
poly_2(F) -> {F(42), F(84)}.
-spec take_boolean(boolean()) -> boolean().
take_boolean(B) -> B.
-spec should_be_rejected() -> {integer(), integer()}.
should_be_rejected() ->
poly_2(fun take_boolean/1).See WhatsApp/eqwalizer#33 for the original issue where this was spotted.