[m-rev.] Fix for inst matching bug
Ralph Becket
rafe at cs.mu.OZ.AU
Mon Jun 20 16:28:36 AEST 2005
This diff replaces the one I posted last week; this change is much
simpler.
Estimated hours taken: 2
Branches: main, release
compiler/inst_util.m:
When comparing insts, allow an unqualified sym_name to match
a qualified sym_name.
Index: compiler/inst_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_util.m,v
retrieving revision 1.36
diff -u -r1.36 inst_util.m
--- compiler/inst_util.m 22 Mar 2005 06:40:01 -0000 1.36
+++ compiler/inst_util.m 20 Jun 2005 04:23:30 -0000
@@ -623,7 +623,11 @@
% alternative for each input doesn't match, then the
% unification can fail, so adjust the determinism.
%
- ( Xs = [functor(ConsId, _)], Ys = [functor(ConsId, _)] ->
+ (
+ Xs = [functor(ConsIdX, _)],
+ Ys = [functor(ConsIdY, _)],
+ cons_ids_match(ConsIdX, ConsIdY)
+ ->
Det = Det0
;
determinism_components(Det0, _, MaxSoln),
@@ -643,7 +647,7 @@
!ModuleInfo) :-
X = functor(ConsIdX, ArgsX),
Y = functor(ConsIdY, ArgsY),
- ( ConsIdX = ConsIdY ->
+ ( cons_ids_match(ConsIdX, ConsIdY) ->
abstractly_unify_inst_list(ArgsX, ArgsY, Live, Real,
Args, Det1, !ModuleInfo),
abstractly_unify_bound_inst_list_2(Live, Xs, Ys, Real,
@@ -679,7 +683,7 @@
L, Det, !ModuleInfo) :-
X = functor(ConsIdX, ArgsX),
(
- ConsIdX = ConsIdY
+ cons_ids_match(ConsIdX, ConsIdY)
->
abstractly_unify_inst_list_lives(ArgsX, ArgsY, LivesY, Real,
Args, Det, !ModuleInfo),
@@ -1680,7 +1684,7 @@
Ys = [Y | Ys1],
X = functor(ConsIdX, ArgsX),
Y = functor(ConsIdY, ArgsY),
- ( ConsIdX = ConsIdY ->
+ ( cons_ids_match(ConsIdX, ConsIdY) ->
maybe_get_cons_id_arg_types(!.ModuleInfo, MaybeType,
ConsIdX, list__length(ArgsX), MaybeTypes),
inst_list_merge(ArgsX, ArgsY, MaybeTypes, Args,
@@ -1744,6 +1748,36 @@
in_mode(InMode),
out_mode(OutMode),
ArgModes = list__duplicate(Arity - 1, InMode) ++ [OutMode].
+
+%-----------------------------------------------------------------------------%
+
+ % A non-module-qualified cons_id name matches a module-qualified
+ % cons_id name.
+ %
+:- pred cons_ids_match(cons_id::in, cons_id::in) is semidet.
+
+cons_ids_match(ConsIdA, ConsIdB) :-
+ (
+ ConsIdA = cons(SymNameA, ArityA),
+ ConsIdB = cons(SymNameB, ArityB)
+ ->
+ ArityA = ArityB,
+ (
+ SymNameA = unqualified(Name),
+ SymNameB = unqualified(Name)
+ ;
+ SymNameA = unqualified(Name),
+ SymNameB = qualified(_, Name)
+ ;
+ SymNameA = qualified(_, Name),
+ SymNameB = unqualified(Name)
+ ;
+ SymNameA = qualified(_, Name),
+ SymNameB = qualified(_, Name)
+ )
+ ;
+ ConsIdA = ConsIdB
+ ).
%-----------------------------------------------------------------------------%
:- end_module inst_util.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list