Add tests for calling constrained functions
This commit is contained in:
parent
6c17e57a7c
commit
fc08fe09a5
@ -2645,6 +2645,14 @@ unify1(_Env, {uvar, A, R}, T, When) ->
|
||||
end;
|
||||
unify1(Env, T, {uvar, A, R}, When) ->
|
||||
unify1(Env, {uvar, A, R}, T, When);
|
||||
unify1(Env, {constrained_t, _, Cs, UVar = {uvar, _, _}}, Type2, When) ->
|
||||
[ add_constraint({is_ord, UVar}) || {id, _, "ord"} <- Cs ],
|
||||
[ add_constraint({is_eq, UVar}) || {id, _, "eq"} <- Cs ],
|
||||
unify1(Env, UVar, Type2, When);
|
||||
unify1(Env, Type1, UVar = {constrained_t, _, Cs, {uvar, _, _}}, When) ->
|
||||
[ add_constraint({is_ord, UVar}) || {id, _, "ord"} <- Cs ],
|
||||
[ add_constraint({is_eq, UVar}) || {id, _, "eq"} <- Cs ],
|
||||
unify1(Env, Type1, UVar, When);
|
||||
unify1(_Env, {tvar, _, X}, {tvar, _, X}, _When) -> true; %% Rigid type variables
|
||||
unify1(_Env, {constrained_t, _, Cs, {tvar, _, X}}, {constrained_t, _, Cs, {tvar, _, X}}, _When) -> true;
|
||||
unify1(Env, [A|B], [C|D], When) ->
|
||||
|
@ -881,7 +881,13 @@ failing_contracts() ->
|
||||
<<?Pos(153,88)
|
||||
"Values of type `custom_record((int, char) => bool)` are not comparable by inequality">>,
|
||||
<<?Pos(154,88)
|
||||
"Values of type `custom_record((int, char) => bool)` are not comparable by equality">>
|
||||
"Values of type `custom_record((int, char) => bool)` are not comparable by equality">>,
|
||||
<<?Pos(158,35)
|
||||
"Values of type `map(int, int)` are not comparable by inequality">>,
|
||||
<<?Pos(159,35)
|
||||
"Values of type `('a) => 'a` are not comparable by inequality">>,
|
||||
<<?Pos(163,34)
|
||||
"Values of type `('b) => 'b` are not comparable by equality">>
|
||||
])
|
||||
, ?TYPE_ERROR(warnings,
|
||||
[<<?Pos(0, 0)
|
||||
|
@ -153,4 +153,13 @@ main contract C =
|
||||
function record_of_nomcomp_ord(x : custom_record(lam), y : custom_record(lam)) = x >= y // fail
|
||||
function record_of_nomcomp_eq (x : custom_record(lam), y : custom_record(lam)) = x == y // pass
|
||||
|
||||
entrypoint init() = ()
|
||||
entrypoint init() =
|
||||
let passing_ord_ord = passing_ord([1], [2]) // pass
|
||||
let passing_ord_eq = passing_ord({[1] = 2}, {[2] = 3}) // fail
|
||||
let passing_ord_noncomp = passing_ord((x) => x, (x) => x) // fail
|
||||
|
||||
let passing_eq_ord = passing_eq([1], [2]) // pass
|
||||
let passing_eq_eq = passing_eq({[1] = 2}, {[2] = 3}) // pass
|
||||
let passing_eq_noncomp = passing_eq((x) => x, (x) => x) // fail
|
||||
|
||||
()
|
Loading…
x
Reference in New Issue
Block a user