[m-rev.] diff: add a test case for a compiler assertion failure

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Dec 2 18:45:43 AEDT 2004


Estimated hours taken: 0.1 (plus a couple of hours isolating this bug)
Branches main.

Add a test case (which we do not currently pass) for an assertion
failure in the compiler.

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
tests/hard_coded/puzzle_detism_bug.exp:
tests/hard_coded/puzzle_detism_bug.m:
	Add a test case for an assertion failure in the compiler.
	(For details see tests/hard_coded/puzzle_detism_bug.m)

Julien.

Index: hard_coded/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mercury.options,v
retrieving revision 1.12
diff -u -r1.12 Mercury.options
--- hard_coded/Mercury.options	19 Nov 2004 11:54:45 -0000	1.12
+++ hard_coded/Mercury.options	2 Dec 2004 07:41:30 -0000
@@ -27,6 +27,7 @@
 MCFLAGS-loop_inv_test0 	= 	--loop-invariants --trace-optimized
 MCFLAGS-loop_inv_test1 	= 	--loop-invariants --trace-optimized
 MCFLAGS-loop_inv_test2 	= 	--loop-invariants --trace-optimized
+MCFLAGS-puzzle_detism_bug = 	--trace-optimized --inlining
 MCFLAGS-no_inline_builtins =	--no-inline-builtins
 MCFLAGS-no_warn_singleton =	--halt-at-warn
 MCFLAGS-nondet_copy_out =	--no-inlining --nondet-copy-out
Index: hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.240
diff -u -r1.240 Mmakefile
--- hard_coded/Mmakefile	8 Nov 2004 02:50:32 -0000	1.240
+++ hard_coded/Mmakefile	2 Dec 2004 07:32:06 -0000
@@ -128,6 +128,7 @@
 	pragma_import \
 	pragma_inline \
 	pretty_printing \
+	puzzle_detism_bug \
 	qual_adv_test \
 	qual_basic_test \
 	qual_is_test \
Index: hard_coded/puzzle_detism_bug.exp
===================================================================
RCS file: hard_coded/puzzle_detism_bug.exp
diff -N hard_coded/puzzle_detism_bug.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hard_coded/puzzle_detism_bug.exp	2 Dec 2004 07:17:40 -0000
@@ -0,0 +1 @@
+James committed the murder with the spanner in the library.
Index: hard_coded/puzzle_detism_bug.m
===================================================================
RCS file: hard_coded/puzzle_detism_bug.m
diff -N hard_coded/puzzle_detism_bug.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hard_coded/puzzle_detism_bug.m	2 Dec 2004 07:40:38 -0000
@@ -0,0 +1,54 @@
+%----------------------------------------------------------------------------%
+%
+% Compiling this on rotd-2004-12-01 and before in any grade and with inlining
+% enabled results in the following assertion failure.
+%
+% 	Uncaught Mercury exception:
+% 	Software Error: inappropriate determinism inside a negation
+%
+% The problem goes away when `--no-inlining' is enabled.
+%
+%----------------------------------------------------------------------------%
+
+:- module puzzle_detism_bug.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module list, string.
+
+main(!IO) :-
+	( solve(james, spanner, library) ->
+		Result = "committed"
+	;
+		Result = "did not commit"
+	),
+	io.write_string("James " ++ Result ++
+		" the murder with the spanner in the library.\n", !IO).
+
+:- type suspect
+	--->	george
+	;	katherine
+	;	james.
+
+:- type weapon
+	--->	knife
+	;	spanner
+	;	candlestick.
+
+:- type room
+	--->	library
+	;	lounge
+	;	conservatory.
+
+:- pred solve(suspect::in, weapon::in, room::in) is semidet.
+
+solve(Suspect, Weapon, Room) :-
+	( Weapon = spanner => ( Room = library ; Room = lounge )),
+	( Weapon = candlestick =>
+		( Suspect = katherine ; Room = conservatory )).

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