[m-rev.] for review: test cases for clause mode annotations
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu May 17 03:45:45 AEST 2001
On 17-May-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> I'll uncomment the commented-out lines,
> changing the problematic one to
>
> { In2 = In },
> print(func2(In, In2)), nl,
>
> to avoid the problem.
>
> I'll also add a new test case tests/valid/mode_selection.m
> which exhibits the problem. This case will not be enabled,
> since we don't yet pass it.
Here's a relative diff for the first part (modifying the test case I posted
earlier) and a full diff for the second part (adding a new test case to test
this other problem). I'll go ahead and commit these.
diff -u multimode.m multimode.m
--- multimode.m
+++ multimode.m
@@ -9,12 +9,16 @@
:- pragma promise_pure(main/2).
main -->
{ In = 42 },
+ { In2 = In }, % this line (and the use of `In2' below,
+ % rather than `In') is needed to avoid
+ % triggering an unrelated bug -- see
+ % tests/valid/mode_selection.m.
% test pure functions
print(func0), nl,
print(func1(In)), nl,
print(func1(_Out0)), nl,
- %print(func2(In, In)), nl,
+ print(func2(In, In2)), nl,
print(func2(In, _Out1)), nl,
print(func2(_Out2, In)), nl,
print(func2(_Out3, _Out4)), nl,
----------
Estimated hours taken: 0.5
Branches: main
tests/valid/Mmakefile:
tests/valid/mode_selection.m:
Add a test case (currently disabled, since we don't pass it)
which tests that we do flattening bottom-up rather than top-down.
Workspace: /home/mars/fjh/ws1/mercury
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.85
diff -u -d -r1.85 Mmakefile
--- tests/valid/Mmakefile 2001/05/16 17:39:44 1.85
+++ tests/valid/Mmakefile 2001/05/16 17:37:09
@@ -163,11 +163,14 @@
vn_float.m \
zero_arity.m
-# The mode system can't handle the following test cases yet:
+# XXX The mode system can't handle the following test cases yet:
# assoc_list.m
# determinism.m
# mode_merge_insts.m
# inst_perf_bug_2.m
+#
+# XXX We also don't pass this one (see the comments in it for details):
+# mode_selection.m
# There used to be problems with compiling typeclass
# and AGC stuff in grades jump.* and fast.*, but they should
Index: tests/valid/mode_selection.m
===================================================================
RCS file: mode_selection.m
diff -N mode_selection.m
--- /dev/null Wed Apr 11 00:52:25 2001
+++ mode_selection.m Thu May 17 03:35:28 2001
@@ -0,0 +1,45 @@
+:- module mode_selection.
+:- interface.
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+:- import_module require.
+
+% Currently (May 2001) we don't pass this test case,
+% because the compiler's expression flattening puts
+% the sub-goals in top-down order, rather than
+% (as the language reference manual requires)
+% ordering them bottom-up. This means that the call to
+% func2 gets flattened as
+% { V_1 = func2(In, V_2) },
+% { V_2 = In },
+% { print(V_1) }
+% rather than as
+% { V_1 = func2(In, V_2) },
+% { V_2 = In },
+% { print(V_1) }
+% which causes mode analysis to select the wrong mode in the
+% call to func2, which in turn causes a determinism error.
+%
+% The rationale for keeping the current behaviour is that
+% the naive fix of just flattening to bottom-up order
+% causes performance problems in type checking, in particular
+% when compiling compiler/options.m.
+% Eventually we ought to change the type checker to use
+% a different algorithm that doesn't have this performance
+% problem, then we can fix flattening, and this test case
+% will then pass.
+
+main -->
+ { In = 42 },
+ print(func2(In, In)), nl.
+
+:- func func2(int, int) = string.
+:- mode func2(in, in) = out is det.
+:- mode func2(in, out) = out is det.
+:- mode func2(out, in) = out is det.
+:- mode func2(out, out) = out is det.
+func2(_, _) = _ :-
+ error("called func2/2").
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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