[m-rev.] diff: fix bug #190 - module qualification of constraint_store attributes
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Mar 17 15:48:51 AEDT 2011
Branches: main, 11.01
Fix bug #190 - mutable definitions attached to the constraint_store attributes
of solver type definitions were not being module qualified.
compiler/module_qual.m:
Do module qualification on the mutable items attached to a solver
type's constraint_store attribute as we do for normal mutable items.
Factor out the code used to module qualify the contents of
item_mutable_info/0 structures into a separate predicate for use
by the above.
tests/valid/Mmakefile:
tests/valid/bug190.m:
Regression test for the above.
Julien.
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.181
diff -u -r1.181 module_qual.m
--- compiler/module_qual.m 7 Mar 2011 03:59:26 -0000 1.181
+++ compiler/module_qual.m 17 Mar 2011 04:33:14 -0000
@@ -908,17 +908,24 @@
Continue = yes
;
Item0 = item_mutable(ItemMutable0),
- ItemMutable0 = item_mutable_info(Name, Type0, InitTerm, Inst0,
- Attrs, Varset, Context, SeqNum),
- mq_info_set_error_context(mqec_mutable(Name) - Context, !Info),
- qualify_type(Type0, Type, !Info, !Specs),
- qualify_inst(Inst0, Inst, !Info, !Specs),
- ItemMutable = item_mutable_info(Name, Type, InitTerm, Inst,
- Attrs, Varset, Context, SeqNum),
+ do_module_qualify_mutable(ItemMutable0, ItemMutable, !Info, !Specs),
Item = item_mutable(ItemMutable),
Continue = yes
).
+:- pred do_module_qualify_mutable(item_mutable_info::in, item_mutable_info::out,
+ mq_info::in, mq_info::out, list(error_spec)::in, list(error_spec)::out)
+ is det.
+
+do_module_qualify_mutable(ItemMutable0, ItemMutable, !Info, !Specs) :-
+ ItemMutable0 = item_mutable_info(Name, Type0, InitTerm, Inst0,
+ Attrs, Varset, Context, SeqNum),
+ mq_info_set_error_context(mqec_mutable(Name) - Context, !Info),
+ qualify_type(Type0, Type, !Info, !Specs),
+ qualify_inst(Inst0, Inst, !Info, !Specs),
+ ItemMutable = item_mutable_info(Name, Type, InitTerm, Inst,
+ Attrs, Varset, Context, SeqNum).
+
:- pred do_module_qualify_event_specs(string::in,
assoc_list(string, event_spec)::in, assoc_list(string, event_spec)::out,
mq_info::in, mq_info::out,
@@ -1013,13 +1020,30 @@
parse_tree_solver_type(SolverTypeDetails, MaybeUserEqComp),
!Info, !Specs) :-
SolverTypeDetails0 = solver_type_details(RepnType0, InitPred,
- GroundInst0, AnyInst0, MutableItems),
+ GroundInst0, AnyInst0, MutableItems0),
qualify_type(RepnType0, RepnType, !Info, !Specs),
qualify_inst(GroundInst0, GroundInst, !Info, !Specs),
qualify_inst(AnyInst0, AnyInst, !Info, !Specs),
+ qualify_constraint_stores(MutableItems0, MutableItems, !Info, !Specs),
SolverTypeDetails = solver_type_details(RepnType, InitPred,
GroundInst, AnyInst, MutableItems).
+:- pred qualify_constraint_stores(list(item)::in, list(item)::out,
+ mq_info::in, mq_info::out,
+ list(error_spec)::in, list(error_spec)::out) is det.
+
+qualify_constraint_stores([], [], !Info, !Specs).
+qualify_constraint_stores([CStore0 | CStores0], [CStore | CStores],
+ !Info, !Specs) :-
+ ( if CStore0 = item_mutable(ItemMutableInfo0) then
+ do_module_qualify_mutable(ItemMutableInfo0, ItemMutableInfo,
+ !Info, !Specs),
+ CStore = item_mutable(ItemMutableInfo)
+ else
+ unexpected($module, $pred, "item is not a mutable")
+ ),
+ qualify_constraint_stores(CStores0, CStores, !Info, !Specs).
+
:- pred qualify_constructors(list(constructor)::in, list(constructor)::out,
mq_info::in, mq_info::out,
list(error_spec)::in, list(error_spec)::out) is det.
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.246
diff -u -r1.246 Mmakefile
--- tests/valid/Mmakefile 6 Feb 2011 07:30:04 -0000 1.246
+++ tests/valid/Mmakefile 17 Mar 2011 04:40:47 -0000
@@ -74,6 +74,7 @@
bug142 \
bug159 \
bug180 \
+ bug190 \
builtin_false \
call_failure \
common_struct_bug \
Index: tests/valid/bug190.m
===================================================================
RCS file: tests/valid/bug190.m
diff -N tests/valid/bug190.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/bug190.m 17 Mar 2011 04:40:19 -0000
@@ -0,0 +1,16 @@
+% A regression test for bug #190.
+% rotd-2011-03-17 and before were not module qualifying mutable definitions
+% attached to the constraint_store attributes of solver types.
+
+:- module bug190.
+:- interface.
+
+:- solver type foo.
+
+:- implementation.
+
+:- import_module list.
+
+:- solver type foo where
+ representation is character,
+ constraint_store is mutable(foo, list(int), [3], ground, [untrailed]).
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list