[m-rev.] diff: detect bad insts in mutables
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Apr 26 16:53:41 AEST 2012
On Mon, 23 Apr 2012, Zoltan Somogyi wrote:
> compiler/hlds_code_util.m:
> Fix a problem I identified in my previous diff, and which Julien
> confirmed in his review: the inst of a mutable must have ALL its
> parts pass the relevant test, not just SOME.
>
> tests/invalid/bad_mutable.{m,err_exp}:
> Add a mutable whose inst contains as components both ground (which is
> ok in mutables) and unique (which is not ok). The old compiler did not
> generate an error for this mutable; the updated compiler does.
The following patch (still pending a bootcheck) fixes a problem with this
and recursive insts such as list_skel.
Julien.
-----------------------
Branches: main
Fix a problem in the mutable inst validity check.
compiler/hlds_code_util.m:
Make the mutable inst validity check handle recursive user defined insts
correctly.
tests/nvalid/uniq_mutable.{m,err_exp}:
Add a test case for the above.
Index: compiler/hlds_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.46
diff -u -r1.46 hlds_code_util.m
--- compiler/hlds_code_util.m 23 Apr 2012 05:49:14 -0000 1.46
+++ compiler/hlds_code_util.m 26 Apr 2012 06:42:53 -0000
@@ -168,10 +168,13 @@
are_valid_mutable_bound_insts(ModuleInfo, BoundInsts, Expansions0)
;
Inst = defined_inst(InstName),
- not set.member(InstName, Expansions0),
- set.insert(InstName, Expansions0, Expansions),
- inst_lookup(ModuleInfo, InstName, SubInst),
- is_valid_mutable_inst_2(ModuleInfo, SubInst, Expansions)
+ ( if not set.member(InstName, Expansions0) then
+ set.insert(InstName, Expansions0, Expansions),
+ inst_lookup(ModuleInfo, InstName, SubInst),
+ is_valid_mutable_inst_2(ModuleInfo, SubInst, Expansions)
+ else
+ true
+ )
).
:- pred are_valid_mutable_bound_insts(module_info::in, list(bound_inst)::in,
Index: tests/invalid/uniq_mutable.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/uniq_mutable.err_exp,v
retrieving revision 1.1
diff -u -r1.1 uniq_mutable.err_exp
--- tests/invalid/uniq_mutable.err_exp 4 Oct 2006 06:37:01 -0000 1.1
+++ tests/invalid/uniq_mutable.err_exp 26 Apr 2012 06:46:54 -0000
@@ -1,10 +1,10 @@
-uniq_mutable.m:012: Error: the inst `unique' is not a valid inst for a mutable
-uniq_mutable.m:012: declaration.
-uniq_mutable.m:013: Error: the inst `mostly_unique' is not a valid inst for a
-uniq_mutable.m:013: mutable declaration.
-uniq_mutable.m:014: Error: the inst `free' is not a valid inst for a mutable
-uniq_mutable.m:014: declaration.
-uniq_mutable.m:015: Error: the inst `clobbered' is not a valid inst for a
-uniq_mutable.m:015: mutable declaration.
-uniq_mutable.m:016: Error: the inst `mostly_clobbered' is not a valid inst for
-uniq_mutable.m:016: a mutable declaration.
+uniq_mutable.m:016: Error: the inst `unique' is not a valid inst for a mutable
+uniq_mutable.m:016: declaration.
+uniq_mutable.m:017: Error: the inst `mostly_unique' is not a valid inst for a
+uniq_mutable.m:017: mutable declaration.
+uniq_mutable.m:018: Error: the inst `free' is not a valid inst for a mutable
+uniq_mutable.m:018: declaration.
+uniq_mutable.m:019: Error: the inst `clobbered' is not a valid inst for a
+uniq_mutable.m:019: mutable declaration.
+uniq_mutable.m:020: Error: the inst `mostly_clobbered' is not a valid inst for
+uniq_mutable.m:020: a mutable declaration.
Index: tests/invalid/uniq_mutable.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/uniq_mutable.m,v
retrieving revision 1.1
diff -u -r1.1 uniq_mutable.m
--- tests/invalid/uniq_mutable.m 4 Oct 2006 06:37:01 -0000 1.1
+++ tests/invalid/uniq_mutable.m 26 Apr 2012 06:45:58 -0000
@@ -6,6 +6,10 @@
:- implementation.
:- import_module io.
+:- import_module list.
+
+:- type io_pred == pred(io, io).
+:- inst io_pred == (pred(di, uo) is det).
% Some invalid mutable insts - we should get error messages.
%
@@ -21,6 +25,7 @@
:- mutable(eta, int, _, any, [untrailed]).
:- mutable(theta, pred(foo), get_foo, (pred(out) is det), [untrailed]).
:- mutable(iota, pred(io, io), io.nl, (pred(di, uo) is det), [untrailed]).
+:- mutable(kappa, list(io_pred), [], list(io_pred), [untrailed]).
:- pred get_foo(foo::out) is det.
--------------------------------------------------------------------------
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