[m-rev.] diff: fix duplicate modes bug
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Jan 17 15:01:02 AEDT 2003
Estimated hours taken: 1
Branches: main, release
Fix a bug reported by Michael Day.
compiler/post_typecheck.m:
Don't attempt to remove duplicate procedures twice.
tests/invalid/duplicate_modes.{m,err_exp}:
Test case.
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.42
diff -u -u -r1.42 post_typecheck.m
--- compiler/post_typecheck.m 14 Jan 2003 16:42:29 -0000 1.42
+++ compiler/post_typecheck.m 17 Jan 2003 03:40:32 -0000
@@ -999,18 +999,22 @@
check_for_indistinguishable_modes(ModuleInfo, PredId, [ProcId | ProcIds],
PrevProcIds, PredInfo0, PredInfo) -->
check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId,
- PrevProcIds, PredInfo0, PredInfo1),
+ PrevProcIds, Removed, PredInfo0, PredInfo1),
+ { PrevProcIds1 =
+ ( if Removed = yes then PrevProcIds
+ else [ProcId | PrevProcIds]
+ ) },
check_for_indistinguishable_modes(ModuleInfo, PredId, ProcIds,
- [ProcId | PrevProcIds], PredInfo1, PredInfo).
+ PrevProcIds1, PredInfo1, PredInfo).
:- pred check_for_indistinguishable_mode(module_info, pred_id, proc_id,
- list(proc_id), pred_info, pred_info, io__state, io__state).
+ list(proc_id), bool, pred_info, pred_info, io__state, io__state).
:- mode check_for_indistinguishable_mode(in, in, in,
- in, in, out, di, uo) is det.
+ in, out, in, out, di, uo) is det.
-check_for_indistinguishable_mode(_, _, _, [], PredInfo, PredInfo) --> [].
+check_for_indistinguishable_mode(_, _, _, [], no, PredInfo, PredInfo) --> [].
check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1,
- [ProcId | ProcIds], PredInfo0, PredInfo) -->
+ [ProcId | ProcIds], Removed, PredInfo0, PredInfo) -->
(
{ modes_are_indistinguishable(ProcId, ProcId1,
PredInfo0, ModuleInfo) }
@@ -1037,12 +1041,12 @@
;
[]
),
- { pred_info_remove_procid(PredInfo0, ProcId1, PredInfo1) }
+ { pred_info_remove_procid(PredInfo0, ProcId1, PredInfo) },
+ { Removed = yes }
;
- { PredInfo1 = PredInfo0 }
- ),
- check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1,
- ProcIds, PredInfo1, PredInfo).
+ check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1,
+ ProcIds, Removed, PredInfo0, PredInfo)
+ ).
%-----------------------------------------------------------------------------%
Index: tests/invalid/duplicate_modes.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/duplicate_modes.err_exp,v
retrieving revision 1.4
diff -u -u -r1.4 duplicate_modes.err_exp
--- tests/invalid/duplicate_modes.err_exp 31 Aug 1999 05:25:59 -0000 1.4
+++ tests/invalid/duplicate_modes.err_exp 17 Jan 2003 02:04:26 -0000
@@ -10,6 +10,12 @@
duplicate_modes.m:008: and `q((ground -> ground), (free -> ground)) is det'
duplicate_modes.m:008: are indistinguishable.
duplicate_modes.m:009: Here is the conflicting mode declaration.
+duplicate_modes.m:008: In mode declarations for predicate `duplicate_modes:q/2':
+duplicate_modes.m:008: error: duplicate mode declaration.
+duplicate_modes.m:008: Modes `q(in, out) is det'
+duplicate_modes.m:008: and `q((ground -> ground), (free -> ground)) is det'
+duplicate_modes.m:008: are indistinguishable.
+duplicate_modes.m:010: Here is the conflicting mode declaration.
duplicate_modes.m:014: In mode declarations for predicate `duplicate_modes:r/2':
duplicate_modes.m:014: error: duplicate mode declaration.
duplicate_modes.m:014: Modes `r(in, in) is semidet'
Index: tests/invalid/duplicate_modes.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/duplicate_modes.m,v
retrieving revision 1.1
diff -u -u -r1.1 duplicate_modes.m
--- tests/invalid/duplicate_modes.m 23 Nov 1997 05:18:41 -0000 1.1
+++ tests/invalid/duplicate_modes.m 17 Jan 2003 02:03:12 -0000
@@ -7,7 +7,7 @@
:- pred q(int, int).
:- mode q(ground -> ground, free -> ground) is det.
:- mode q(in, out) is det.
-
+:- mode q(in, out) is det.
q(X, X).
:- pred r(int, int).
--------------------------------------------------------------------------
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