Files
mercury/tests/valid/overloading.m
Mark Brown 2629aca5a3 Fix a bug in overloading resolution.
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.
2005-11-14 05:14:13 +00:00

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.