[m-rev.] diff: fix a badly formed error message

Julien Fischer juliensf at cs.mu.OZ.AU
Fri Jun 16 16:08:13 AEST 2006


Estimated hours taken: 1
Branches: main, release

Fix a badly formed determinism error message.  If a det predicate called a
nondet goal the resulting error message ended with two incomplete sentences,
e.g.

	a.m:014:   call to `a.nondet_pred(in, out)'
	a.m:014:   can fail.
	a.m:014:   can succeed more than once.

compiler/det_report.m:
	Fix det_diagnose_atomic_goal/6 to handle the situation where
	determinism errors are caused by nondet goals.

tests/invalid/Mmakefile:
tests/invalid/det_atomic_goal_msgs.{m,err_exp}:
	Add a test case for the above.

Julien.

Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.120
diff -u -r1.120 det_report.m
--- compiler/det_report.m	14 Jun 2006 07:42:53 -0000	1.120
+++ compiler/det_report.m	16 Jun 2006 05:48:37 -0000
@@ -730,18 +730,24 @@
     determinism_components(Actual, ActualCanFail, ActualSolns),
     compare_canfails(DesiredCanFail, ActualCanFail, CmpCanFail),
     ( CmpCanFail = tighter ->
-        add_to_spec_at_end([words("can fail."), nl], !CurSpec),
+        add_to_spec_at_end([words("can fail")], !CurSpec),
         Diagnosed1 = yes
     ;
         Diagnosed1 = no
     ),
     compare_solncounts(DesiredSolns, ActualSolns, CmpSolns),
     ( CmpSolns = tighter ->
+        (
+            Diagnosed1 = yes,
+            add_to_spec_at_end([words("and")], !CurSpec)
+        ;
+            Diagnosed1 = no
+        ),
         ( DesiredSolns = at_most_one ->
-            add_to_spec_at_end([words("can succeed more than once."), nl],
+            add_to_spec_at_end([words("can succeed more than once")],
                 !CurSpec)
         ;
-            add_to_spec_at_end([words("can succeed."), nl], !CurSpec)
+            add_to_spec_at_end([words("can succeed")], !CurSpec)
         ),
         Diagnosed2 = yes
     ;
@@ -749,7 +755,8 @@
     ),
     bool.or(Diagnosed1, Diagnosed2, Diagnosed),
     (
-        Diagnosed = yes
+        Diagnosed = yes,
+        add_to_spec_at_end([suffix("."), nl], !CurSpec)
     ;
         Diagnosed = no,
         Pieces = [words("has unknown determinism problem;"), nl,
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.192
diff -u -r1.192 Mmakefile
--- tests/invalid/Mmakefile	14 Jun 2006 08:14:51 -0000	1.192
+++ tests/invalid/Mmakefile	16 Jun 2006 06:00:51 -0000
@@ -64,6 +64,7 @@
 	cyclic_typeclass \
 	cyclic_typeclass_2 \
 	cyclic_typeclass_3 \
+	det_atomic_goal_msgs \
 	det_errors \
 	det_errors_cc \
 	duplicate_modes \
Index: tests/invalid/det_atomic_goal_msgs.err_exp
===================================================================
RCS file: tests/invalid/det_atomic_goal_msgs.err_exp
diff -N tests/invalid/det_atomic_goal_msgs.err_exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/det_atomic_goal_msgs.err_exp	16 Jun 2006 05:58:35 -0000
@@ -0,0 +1,23 @@
+det_atomic_goal_msgs.m:004: In `det_calls_failure(in, out)':
+det_atomic_goal_msgs.m:004:   error: determinism declaration not satisfied.
+det_atomic_goal_msgs.m:004:   Declared `det', inferred `failure'.
+det_atomic_goal_msgs.m:011:   call to `det_atomic_goal_msgs.failure_pred(in)'
+det_atomic_goal_msgs.m:011:   can fail.
+det_atomic_goal_msgs.m:005: In `det_calls_semidet(in, out)':
+det_atomic_goal_msgs.m:005:   error: determinism declaration not satisfied.
+det_atomic_goal_msgs.m:005:   Declared `det', inferred `semidet'.
+det_atomic_goal_msgs.m:012:   call to `det_atomic_goal_msgs.semidet_pred(in)'
+det_atomic_goal_msgs.m:012:   can fail.
+det_atomic_goal_msgs.m:006: In `det_calls_multi(out)':
+det_atomic_goal_msgs.m:006:   error: determinism declaration not satisfied.
+det_atomic_goal_msgs.m:006:   Declared `det', inferred `multi'.
+det_atomic_goal_msgs.m:013:   call to `det_atomic_goal_msgs.multi_pred(out)'
+det_atomic_goal_msgs.m:013:   can succeed more than once.
+det_atomic_goal_msgs.m:007: In `det_calls_nondet(in, out)':
+det_atomic_goal_msgs.m:007:   error: determinism declaration not satisfied.
+det_atomic_goal_msgs.m:007:   Declared `det', inferred `nondet'.
+det_atomic_goal_msgs.m:014:   call to `det_atomic_goal_msgs.nondet_pred(in,
+det_atomic_goal_msgs.m:014:   out)' can fail and can succeed more than once.
+det_atomic_goal_msgs.m:034: In `failure_pred(in)':
+det_atomic_goal_msgs.m:034:   error: determinism declaration not satisfied.
+det_atomic_goal_msgs.m:034:   Declared `failure', inferred `det'.
Index: tests/invalid/det_atomic_goal_msgs.m
===================================================================
RCS file: tests/invalid/det_atomic_goal_msgs.m
diff -N tests/invalid/det_atomic_goal_msgs.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/det_atomic_goal_msgs.m	16 Jun 2006 06:00:20 -0000
@@ -0,0 +1,40 @@
+%
+% rotd-2006-06-15 printed out a badly formed error message for
+% det_calls_nondet/2.
+%
+:- module det_atomic_goal_msgs.
+:- interface.
+
+:- pred det_calls_failure(int::in, int::out) is det.
+:- pred det_calls_semidet(int::in, int::out) is det.
+:- pred det_calls_multi(int::out) is det.
+:- pred det_calls_nondet(int::in, int::out) is det.
+
+:- implementation.
+
+det_calls_failure(X, 4)   :- failure_pred(X).
+det_calls_semidet(X, 4)   :- semidet_pred(X).
+det_calls_multi(X)        :- multi_pred(X).
+det_calls_nondet(X, Y)    :- nondet_pred(X, Y).
+
+:- pred nondet_pred(int::in, int::out) is nondet.
+
+nondet_pred(1, 2).
+nondet_pred(1, 3).
+nondet_pred(2, 2).
+nondet_pred(3, 2).
+
+:- pred multi_pred(int::out) is multi.
+
+multi_pred(1).
+multi_pred(2).
+multi_pred(3).
+multi_pred(4).
+
+:- pred semidet_pred(int::in) is semidet.
+
+semidet_pred(3).
+
+:- pred failure_pred(int::in) is failure.
+
+failure_pred(_).

--------------------------------------------------------------------------
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