[m-rev.] diff: fix bug 159

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Sep 14 19:07:32 AEST 2010


Fix Mantis bug #159.

compiler/modecheck_goal.m:
compiler/unique_modes.m:
	Fix two occurrences of the same bug. The bug was both plain mode
	checking and unique mode checking, when processing from_ground_term
	scopes, neglected to test whether the variable being constructed was
	live or not, and thus did not delete the scope in cases where it was
	not live, even though they both delete construction unifications in
	such circumstances.

compiler/modecheck_unify.m:
compiler/simplify.m:
	Improve the code style.

tests/valid/bug159.m:
	Add the regression test for this bug.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
	Enable the test case.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/extra
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/extra
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/doc
cvs diff: Diffing boehm_gc/libatomic_ops/src
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/armcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops/tests
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/m4
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/modecheck_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_goal.m,v
retrieving revision 1.1
diff -u -b -r1.1 modecheck_goal.m
--- compiler/modecheck_goal.m	25 Sep 2009 05:13:05 -0000	1.1
+++ compiler/modecheck_goal.m	14 Sep 2010 06:45:17 -0000
@@ -803,8 +803,10 @@
         Reason = from_ground_term(TermVar, _),
         mode_checkpoint(enter, "scope", !ModeInfo),
         modecheck_goal_from_ground_term_scope(TermVar, SubGoal0, GoalInfo0,
-            Kind1, SubGoal1, !ModeInfo),
+            MaybeKind1AndSubGoal1, !ModeInfo),
         mode_checkpoint(exit, "scope", !ModeInfo),
+        (
+            MaybeKind1AndSubGoal1 = yes(Kind1 - SubGoal1),
         mode_info_set_had_from_ground_term(had_from_ground_term_scope,
             !ModeInfo),
 
@@ -830,6 +832,10 @@
             )
         )
     ;
+            MaybeKind1AndSubGoal1 = no,
+            GoalExpr = conj(plain_conj, [])
+        )
+    ;
         Reason = promise_purity(_Purity),
         mode_info_get_in_promise_purity_scope(!.ModeInfo, InPPScope),
         mode_info_set_in_promise_purity_scope(in_promise_purity_scope,
@@ -976,11 +982,12 @@
     mode_info_set_module_info(ModuleInfo, !ModeInfo).
 
 :- pred modecheck_goal_from_ground_term_scope(prog_var::in,
-    hlds_goal::in, hlds_goal_info::in, from_ground_term_kind::out,
-    hlds_goal::out, mode_info::in, mode_info::out) is det.
+    hlds_goal::in, hlds_goal_info::in,
+    maybe(pair(from_ground_term_kind, hlds_goal))::out,
+    mode_info::in, mode_info::out) is det.
 
 modecheck_goal_from_ground_term_scope(TermVar, SubGoal0, GoalInfo0,
-        Kind, SubGoal, !ModeInfo) :-
+        MaybeKindAndSubGoal, !ModeInfo) :-
     % The original goal does no quantification, so deleting the `scope'
     % would be OK. However, deleting it during mode analysis would mean
     % we don't have it during unique mode analysis and other later compiler
@@ -992,10 +999,19 @@
         MaybeGroundTermMode),
     (
         MaybeGroundTermMode = yes(construct_ground_term(RevConj0)),
+        mode_info_var_is_live(!.ModeInfo, TermVar, LiveTermVar),
+        (
+            LiveTermVar = is_live,
         SubGoal0 = hlds_goal(_, SubGoalInfo0),
         modecheck_ground_term_construct(TermVar, RevConj0,
             SubGoalInfo0, VarSet, SubGoal, !ModeInfo),
-        Kind = from_ground_term_construct
+            Kind = from_ground_term_construct,
+            MaybeKindAndSubGoal = yes(Kind - SubGoal)
+        ;
+            LiveTermVar = is_dead,
+            % The term constructed by the scope is not used anywhere.
+            MaybeKindAndSubGoal = no
+        )
     ;
         (
             MaybeGroundTermMode = yes(deconstruct_ground_term(_)),
@@ -1030,7 +1046,8 @@
         ),
         mode_checkpoint(enter, "scope", !ModeInfo),
         modecheck_goal(SubGoal2, SubGoal, !ModeInfo),
-        mode_checkpoint(exit, "scope", !ModeInfo)
+        mode_checkpoint(exit, "scope", !ModeInfo),
+        MaybeKindAndSubGoal = yes(Kind - SubGoal)
     ).
 
 :- type ground_term_mode
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.134
diff -u -b -r1.134 modecheck_unify.m
--- compiler/modecheck_unify.m	25 Sep 2009 05:13:05 -0000	1.134
+++ compiler/modecheck_unify.m	14 Sep 2010 06:45:17 -0000
@@ -225,8 +225,8 @@
         )
     ;
         set.list_to_set([X, Y], WaitingVars),
-        mode_info_error(WaitingVars,
-            mode_error_unify_var_var(X, Y, InstOfX, InstOfY), !ModeInfo),
+        ModeError = mode_error_unify_var_var(X, Y, InstOfX, InstOfY),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo),
             % If we get an error, set the inst to not_reached to suppress
             % follow-on errors. But don't call categorize_unification, because
             % that could cause an invalid call to `unify_proc.request_unify'
@@ -468,8 +468,8 @@
             NonGroundNonLocals = [BadVar | _],
             instmap_lookup_var(InstMap1, BadVar, BadInst),
             set.singleton_set(WaitingVars, BadVar),
-            mode_info_error(WaitingVars,
-                mode_error_non_local_lambda_var(BadVar, BadInst), !ModeInfo)
+            ModeError = mode_error_non_local_lambda_var(BadVar, BadInst),
+            mode_info_error(WaitingVars, ModeError, !ModeInfo)
         ;
             NonGroundNonLocals = [],
             unexpected(this_file,
@@ -512,9 +512,8 @@
         modecheck_set_var_inst(X, Inst, no, !ModeInfo)
     ;
         set.list_to_set([X], WaitingVars),
-        mode_info_error(WaitingVars,
-            mode_error_unify_var_lambda(X, InstOfX, InstOfY),
-            !ModeInfo),
+        ModeError = mode_error_unify_var_lambda(X, InstOfX, InstOfY),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo),
         % If we get an error, set the inst to not_reached to avoid cascading
         % errors. But don't call categorize_unification, because that could
         % cause an invalid call to `unify_proc.request_unify'
@@ -549,8 +548,8 @@
             ( MatchResult = possible_modes([])
             ; MatchResult = ho_arg_not_ground
             ),
-            mode_info_error(set.make_singleton_set(X),
-                mode_error_unify_var_multimode_pred(X, PredId), !ModeInfo),
+            ModeError = mode_error_unify_var_multimode_pred(X, PredId),
+            mode_info_error(set.make_singleton_set(X), ModeError, !ModeInfo),
             % Return any old garbage.
             Goal = true_goal_expr
         ;
@@ -563,9 +562,9 @@
                 GoalInfo, Goal, !ModeInfo)
         ;
             MatchResult = possible_modes([_, _ | _]),
-            mode_info_error(set.make_singleton_set(X),
+            ModeError =
                 mode_error_unify_var_multimode_pred_undetermined(X, PredId),
-                !ModeInfo),
+            mode_info_error(set.make_singleton_set(X), ModeError, !ModeInfo),
             % Return any old garbage.
             Goal = true_goal_expr
         )
@@ -658,10 +657,9 @@
         \+ inst_is_ground(ModuleInfo0, InstOfX)
     ->
         set.list_to_set([X], WaitingVars),
-        mode_info_error(WaitingVars,
-            mode_error_unify_var_functor(X, InstConsId, ArgVars0,
+        ModeError = mode_error_unify_var_functor(X, InstConsId, ArgVars0,
                 InstOfX, InstArgs),
-            !ModeInfo),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo),
         Inst = not_reached,
         Det = detism_erroneous,
         % If we get an error, set the inst to not_reached to avoid cascading
@@ -746,10 +744,9 @@
         )
     ;
         set.list_to_set([X | ArgVars0], WaitingVars), % conservative
-        mode_info_error(WaitingVars,
-            mode_error_unify_var_functor(X, InstConsId, ArgVars0,
+        ModeError = mode_error_unify_var_functor(X, InstConsId, ArgVars0,
                 InstOfX, InstArgs),
-            !ModeInfo),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo),
         % If we get an error, set the inst to not_reached to avoid cascading
         % errors. But don't call categorize_unification, because that could
         % cause an invalid call to `unify_proc.request_unify'.
@@ -1200,15 +1197,15 @@
         \+ inst_is_ground_or_any(ModuleInfo3, InitialInstX)
     ->
         set.singleton_set(WaitingVars, X),
-        mode_info_error(WaitingVars, mode_error_poly_unify(X, InitialInstX),
-            !ModeInfo)
+        ModeError = mode_error_poly_unify(X, InitialInstX),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo)
     ;
         Type = type_variable(_, _),
         \+ inst_is_ground_or_any(ModuleInfo3, InitialInstY)
     ->
         set.singleton_set(WaitingVars, Y),
-        mode_info_error(WaitingVars, mode_error_poly_unify(Y, InitialInstY),
-            !ModeInfo)
+        ModeError = mode_error_poly_unify(Y, InitialInstY),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo)
     ;
         % Check that we're not trying to do a higher-order unification.
         type_is_higher_order_details(Type, _, PredOrFunc, _, _)
@@ -1229,9 +1226,9 @@
             true
         ;
             set.init(WaitingVars),
-            mode_info_error(WaitingVars,
+            ModeError =
                 mode_error_unify_pred(X, error_at_var(Y), Type, PredOrFunc),
-                !ModeInfo)
+            mode_info_error(WaitingVars, ModeError, !ModeInfo)
         )
     ;
         % Ensure that we will generate code for the unification procedure
@@ -1342,10 +1339,9 @@
         set.init(WaitingVars),
         mode_info_get_var_types(!.ModeInfo, VarTypes0),
         map.lookup(VarTypes0, X, Type),
-        mode_info_error(WaitingVars,
-            mode_error_unify_pred(X, error_at_lambda(ArgVars, ArgModes0),
-                Type, PredOrFunc),
-            !ModeInfo),
+        ModeError = mode_error_unify_pred(X,
+            error_at_lambda(ArgVars, ArgModes0), Type, PredOrFunc),
+        mode_info_error(WaitingVars, ModeError, !ModeInfo),
         % Return any old garbage.
         Unification = Unification0,
         RHS = RHS0
@@ -1439,10 +1435,9 @@
                 instmap_is_reachable(InstMap0)
             ->
                 set.init(WaitingVars),
-                mode_info_error(WaitingVars,
-                    mode_error_unify_pred(X, error_at_functor(ConsId, ArgVars),
-                        TypeOfX, PredOrFunc),
-                    !ModeInfo)
+                ModeError = mode_error_unify_pred(X,
+                    error_at_functor(ConsId, ArgVars), TypeOfX, PredOrFunc),
+                mode_info_error(WaitingVars, ModeError, !ModeInfo)
             ;
                 true
             )
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.250
diff -u -b -r1.250 simplify.m
--- compiler/simplify.m	4 Aug 2010 02:44:11 -0000	1.250
+++ compiler/simplify.m	14 Sep 2010 06:45:17 -0000
@@ -3169,8 +3169,8 @@
         Goals, !RevGoals, !Subn).
 
 :- pred goal_is_excess_assign(trace_level::in, bool::in, prog_varset::in,
-    set(prog_var)::in, hlds_goal::in, var_renaming::in,
-    var_renaming::out) is semidet.
+    set(prog_var)::in, hlds_goal::in,
+    var_renaming::in, var_renaming::out) is semidet.
 
 goal_is_excess_assign(Trace, TraceOptimized, VarSet, ConjNonLocals, Goal0,
         !Subn) :-
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.133
diff -u -b -r1.133 unique_modes.m
--- compiler/unique_modes.m	25 Sep 2009 05:13:06 -0000	1.133
+++ compiler/unique_modes.m	14 Sep 2010 06:45:17 -0000
@@ -153,8 +153,7 @@
         mode_info_set_nondet_live_vars(bag.init, !ModeInfo)
     ),
 
-    unique_modes_check_goal_expr(GoalExpr0, GoalInfo0, GoalExpr,
-        !ModeInfo),
+    unique_modes_check_goal_expr(GoalExpr0, GoalInfo0, GoalExpr, !ModeInfo),
     % Restore the original bag of nondet-live vars.
     mode_info_set_nondet_live_vars(NondetLiveVars0, !ModeInfo),
 
@@ -307,8 +306,7 @@
             !ModeInfo)
     ;
         GoalExpr0 = scope(Reason0, SubGoal0),
-        unique_modes_check_goal_scope(Reason0, SubGoal0, GoalExpr,
-            !ModeInfo)
+        unique_modes_check_goal_scope(Reason0, SubGoal0, GoalExpr, !ModeInfo)
     ;
         GoalExpr0 = shorthand(ShortHand0),
         (
@@ -504,9 +502,12 @@
 unique_modes_check_goal_scope(Reason, SubGoal0, GoalExpr, !ModeInfo) :-
     mode_checkpoint(enter, "scope", !ModeInfo),
     ( Reason = from_ground_term(TermVar, from_ground_term_construct) ->
+        mode_info_var_is_live(!.ModeInfo, TermVar, LiveTermVar),
+        (
+            LiveTermVar = is_live,
         % The subgoal was left in its final state during (non-unique) mode
-        % checking. All we need to do here is to add the relevant information
-        % in the goal to ModeInfo.
+            % checking. All we need to do here is to add the relevant
+            % information in the goal to ModeInfo.
         SubGoal = SubGoal0,
         SubGoal = hlds_goal(_, SubGoalInfo),
         InstMapDelta = goal_info_get_instmap_delta(SubGoalInfo),
@@ -516,12 +517,18 @@
             mode_info_set_instmap(InstMap, !ModeInfo)
         ;
             unexpected(this_file,
-                "unique_modes_check_goal_scope: term var not in InstMapDelta")
+                    "unique_modes_check_goal_scope: bad InstMapDelta")
+            ),
+            GoalExpr = scope(Reason, SubGoal)
+        ;
+            LiveTermVar = is_dead,
+            % The term constructed by the scope is not used anywhere.
+            GoalExpr = conj(plain_conj, [])
         )
     ;
-        unique_modes_check_goal(SubGoal0, SubGoal, !ModeInfo)
+        unique_modes_check_goal(SubGoal0, SubGoal, !ModeInfo),
+        GoalExpr = scope(Reason, SubGoal)
     ),
-    GoalExpr = scope(Reason, SubGoal),
     mode_checkpoint(exit, "scope", !ModeInfo).
 
 :- pred unique_modes_check_goal_generic_call(generic_call::in,
cvs diff: Diffing compiler/notes
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_cairo
cvs diff: Diffing extras/graphics/mercury_cairo/samples
cvs diff: Diffing extras/graphics/mercury_cairo/samples/data
cvs diff: Diffing extras/graphics/mercury_cairo/tutorial
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/monte
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/java_interface
cvs diff: Diffing samples/java_interface/java_calls_mercury
cvs diff: Diffing samples/java_interface/mercury_calls_java
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/stm
cvs diff: Diffing tests/stm/orig
cvs diff: Diffing tests/stm/orig/stm-compiler
cvs diff: Diffing tests/stm/orig/stm-compiler/test1
cvs diff: Diffing tests/stm/orig/stm-compiler/test10
cvs diff: Diffing tests/stm/orig/stm-compiler/test2
cvs diff: Diffing tests/stm/orig/stm-compiler/test3
cvs diff: Diffing tests/stm/orig/stm-compiler/test4
cvs diff: Diffing tests/stm/orig/stm-compiler/test5
cvs diff: Diffing tests/stm/orig/stm-compiler/test6
cvs diff: Diffing tests/stm/orig/stm-compiler/test7
cvs diff: Diffing tests/stm/orig/stm-compiler/test8
cvs diff: Diffing tests/stm/orig/stm-compiler/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/bm2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/stmqueue
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test10
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test11
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par/test9
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test1
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test2
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test3
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test4
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test5
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test6
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test7
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test8
cvs diff: Diffing tests/stm/orig/stm-compiler-par-asm_fast/test9
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.69
diff -u -b -r1.69 Mercury.options
--- tests/valid/Mercury.options	14 Sep 2010 02:22:56 -0000	1.69
+++ tests/valid/Mercury.options	14 Sep 2010 06:44:47 -0000
@@ -44,6 +44,7 @@
 MCFLAGS-bug100                  = --halt-at-warn
 MCFLAGS-bug134                  = --no-static-ground-terms --no-optimize-dead-procs
 MCFLAGS-bug142                  = --optimise-higher-order --inline-single-use
+MCFLAGS-bug159                  = -w
 MCFLAGS-compl_unify_bug		= -O3
 MCFLAGS-constraint_prop_bug	= -O0 --common-struct --local-constraint-propagation
 MCFLAGS-csharp_hello		= --no-intermodule-optimization
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.242
diff -u -b -r1.242 Mmakefile
--- tests/valid/Mmakefile	14 Sep 2010 02:22:56 -0000	1.242
+++ tests/valid/Mmakefile	14 Sep 2010 06:44:23 -0000
@@ -71,6 +71,7 @@
 	bug100 \
 	bug134 \
 	bug142 \
+	bug159 \
 	builtin_false \
 	call_failure \
 	common_struct_bug \
Index: tests/valid/bug159.m
===================================================================
RCS file: tests/valid/bug159.m
diff -N tests/valid/bug159.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/bug159.m	14 Sep 2010 06:44:09 -0000
@@ -0,0 +1,50 @@
+% vim: ts=4 sw=4 et ft=mercury
+% This is a test case for Mantis bug 159. The bug was that mode checking and
+% unique mode checking did not eliminate a from_ground_term scope that
+% constructed a variable which was unused except for its type (variable L
+% in pickles/0 below), even though they eliminated construction unifications
+% that constructed similarly unused variables.
+
+:- module bug159.
+
+:- interface.
+
+:- type pickles ---> pickles(int).
+
+:- func pickles = pickles.
+
+:- implementation.
+
+:- import_module int.
+:- import_module list.
+:- import_module univ.
+:- import_module type_desc.
+:- import_module construct.
+:- import_module deconstruct.
+:- import_module require.
+
+:- pragma memo(pickles/0).
+
+pickles = !:P :-
+    !:P = pickles(0),
+    % The size of this term should be (and currently is) above the
+    % from_ground_term threshold.
+    L = [1,2,3],
+    register_pickle(type_ctor(type_of(L)), pickle_list_as_array, !P).
+
+:- type byte_buffer == int.
+
+:- type maybe_pickle == pred(pickles, univ, byte_buffer, byte_buffer).
+:- inst maybe_pickle == (pred(in, in, di, uo) is det).
+
+:- pred register_pickle(type_ctor_desc::in, maybe_pickle::in(maybe_pickle),
+    pickles::in, pickles::out) is det.
+
+register_pickle(_T, _N, pickles(I), pickles(I+1)) :-
+    true.
+
+:- pred pickle_list_as_array `with_type` maybe_pickle `with_inst` maybe_pickle.
+
+pickle_list_as_array(_Pickles, _UnivList, !BB) :-
+    error("foo").
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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