Files
mercury/tests/hard_coded/closure_arg_comparison.m
Ian MacLarty bab5d1a08e Fixed bug where the arguments of a closure were being compared normally,
Estimated hours taken: 6
Branches: main

Fixed bug where the arguments of a closure were being compared normally,
instead of having their representations compared.

Also fixed some copy-paste errors in the comments for list.foldl3 and foldl4.

library/list.m
	Fixed comments for foldl3 and foldl4.

runtime/mercury_ho_call.c
	When comparing the arguments of a closure use
	MR_generic_compare_representation, instead of MR_generic_compare, since
	one of the arguments may itself be a closure.  Renamed
	MR_compare_closures to MR_compare_closures_representation to make it
	clear that the representation is being compared.

runtime/mercury_unify_compare_body.h
	Changed call to MR_compare_closure to
	MR_compare_closure_representation.

tests/hard_coded/closure_arg_comparison.m
	Test the bug fix.  Before the fix this program would terminate with
	"Mercury runtime: attempt to compare higher-order terms".

tests/hard_coded/closure_arg_comparison.exp
	Expected output.
2004-07-26 03:19:28 +00:00

30 lines
439 B
Mathematica

:- module closure_arg_comparison.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is cc_multi.
:- implementation.
:- import_module int.
main(!IO) :-
compare_representation(R, p(q(1)), p(r(1))),
write(R, !IO),
nl(!IO).
:- pred p(pred(int), int).
:- mode p(pred(out) is det, out) is det.
p(P, X) :- P(Y), X = Y+1.
:- pred q(int::in, int::out) is det.
q(X, X+4).
:- pred r(int::in, int::out) is det.
r(X, X+5).