mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-25 22:34:26 +00:00
Estimated hours taken: 5 Branches: main Fix a bug in overloading resolution. compiler/post_typecheck.m: Make the constraint map available when resolving unifications with overloaded functors. compiler/hlds_module.m: Use the constraint map, if available, to rule out possible pred_ids when resolving overloading. compiler/hlds_data.m: Provide a means to search the constraint map and fail rather than abort if the constraints aren't found. compiler/intermod.m: Update for the changed interface in hlds_module.m. tests/valid/Mmakefile: tests/valid/overloading.m: New test case.
20 lines
362 B
Mathematica
20 lines
362 B
Mathematica
:- module overloading.
|
|
:- interface.
|
|
|
|
:- type foo(T)
|
|
---> f1(T, T)
|
|
; f2.
|
|
|
|
:- pred bar(foo(T)::in, T::in) is semidet.
|
|
|
|
:- implementation.
|
|
|
|
% The symbol f1/2 is overloaded here, but the overloading is resolved
|
|
% because the baz/1 constraint cannot be reduced.
|
|
bar(f1(X, _), X).
|
|
|
|
:- typeclass baz(T) where [].
|
|
:- func f1(T, T) = foo(T) <= baz(T).
|
|
f1(_, _) = f2.
|
|
|