[m-rev.] diff: erroneous trace goals

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Aug 17 13:27:21 AEST 2011


Fix a bug that caused the compiler to mishandle code like this:

	test(X, Y) :-
	    ( X < 10 ->
		X = Y
	    ;
		trace [compiletime(flag("flag_is_not_set"))] (
		    error("error_is_not_thrown")
		),
		Y = X + 1
	    ).

The problem was that the compiler deleted everything after the call to error
as unreachable code, even though the trace scope may not be enabled, and if
it isn't, then the code after it WILL be reached.

compiler/det_analysis.m:
	Fix the bug.

compiler/modecheck_goal.m:
compiler/modes.m:
compiler/unique_modes.m:
	Do not allow goals in trace scopes to bind variables in unique_modes.m.
	We already disallow this during ordinary mode checking; do likewise
	during unique mode checking.

	When --debug-modes enables progress messages from the modechecker,
	make the messages for scopes more specific, to help track down
	problems like this.

	Make the debug progress messages also indicate procedure boundaries
	and entries into and exits from more kinds of goals, again to help
	to track down problems like this.

	Put some argument lists in a more logical order.

tests/hard_coded/conditional_trace_scope.{m,exp}:
	A regression test case for the bug.

tests/hard_coded/Mmakefile:
	Enable the new test case.

Zoltan.

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/det_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.232
diff -u -b -r1.232 det_analysis.m
--- compiler/det_analysis.m	16 Aug 2011 03:26:30 -0000	1.232
+++ compiler/det_analysis.m	17 Aug 2011 03:13:58 -0000
@@ -1732,14 +1732,26 @@
         Reason = trace_goal(_, _, _, _, _),
         det_infer_goal(Goal0, Goal, InstMap0, SolnContext,
             RightFailingContexts, MaybePromiseEqvSolutionSets0,
-            Detism, GoalFailingContexts, !DetInfo),
+            Detism0, GoalFailingContexts, !DetInfo),
         (
-            ( Detism = detism_det
-            ; Detism = detism_cc_multi
+            % Since the trace goal may not be enabled, it would be incorrect
+            % to say that it ALWAYS aborts. That is why we convert a detism
+            % of detism_erroneous inside the scope to detism_det outside the 
+            % scope.
+            (
+                Detism0 = detism_det,
+                Detism1 = detism_det
+            ;
+                Detism0 = detism_cc_multi,
+                Detism1 = detism_cc_multi
+            ;
+                Detism0 = detism_erroneous,
+                Detism1 = detism_det
             )
         ->
-            true
+            Detism = Detism1
         ;
+            Detism = Detism0,
             Context = goal_info_get_context(GoalInfo),
             DetismStr = determinism_to_string(Detism),
             Pieces = [words("Error: trace goal has determinism"),
Index: compiler/modecheck_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_goal.m,v
retrieving revision 1.9
diff -u -b -r1.9 modecheck_goal.m
--- compiler/modecheck_goal.m	16 Aug 2011 03:26:32 -0000	1.9
+++ compiler/modecheck_goal.m	16 Aug 2011 04:04:01 -0000
@@ -217,8 +217,7 @@
             GoalInfo0, GoalExpr, !ModeInfo)
     ;
         GoalExpr0 = conj(ConjType, Goals),
-        modecheck_goal_conj(ConjType, Goals, GoalInfo0, GoalExpr,
-            !ModeInfo)
+        modecheck_goal_conj(ConjType, Goals, GoalInfo0, GoalExpr, !ModeInfo)
     ;
         GoalExpr0 = disj(Goals),
         modecheck_goal_disj(Goals, GoalInfo0, GoalExpr, !ModeInfo)
@@ -786,7 +785,7 @@
 modecheck_goal_scope(Reason, SubGoal0, GoalInfo0, GoalExpr, !ModeInfo) :-
     (
         Reason = trace_goal(_, _, _, _, _),
-        mode_checkpoint(enter, "scope", !ModeInfo),
+        mode_checkpoint(enter, "trace scope", !ModeInfo),
         mode_info_get_instmap(!.ModeInfo, InstMap0),
         NonLocals = goal_info_get_nonlocals(GoalInfo0),
         % We need to lock the non-local variables, to ensure that
@@ -797,7 +796,7 @@
         mode_info_unlock_vars(var_lock_trace_goal, NonLocals, !ModeInfo),
         mode_info_set_instmap(InstMap0, !ModeInfo),
         GoalExpr = scope(Reason, SubGoal),
-        mode_checkpoint(exit, "scope", !ModeInfo)
+        mode_checkpoint(exit, "trace scope", !ModeInfo)
     ;
         ( Reason = exist_quant(_)
         ; Reason = promise_solutions(_, _)
@@ -812,10 +811,10 @@
         mode_checkpoint(exit, "scope", !ModeInfo)
     ;
         Reason = from_ground_term(TermVar, _),
-        mode_checkpoint(enter, "scope", !ModeInfo),
+        mode_checkpoint(enter, "from_ground_term scope", !ModeInfo),
         modecheck_goal_from_ground_term_scope(TermVar, SubGoal0, GoalInfo0,
             MaybeKind1AndSubGoal1, !ModeInfo),
-        mode_checkpoint(exit, "scope", !ModeInfo),
+        mode_checkpoint(exit, "from_ground_term scope", !ModeInfo),
         (
             MaybeKind1AndSubGoal1 = yes(Kind1 - SubGoal1),
             mode_info_set_had_from_ground_term(had_from_ground_term_scope,
@@ -851,10 +850,10 @@
         mode_info_get_in_promise_purity_scope(!.ModeInfo, InPPScope),
         mode_info_set_in_promise_purity_scope(in_promise_purity_scope,
             !ModeInfo),
-        mode_checkpoint(enter, "scope", !ModeInfo),
+        mode_checkpoint(enter, "promise_purity scope", !ModeInfo),
         modecheck_goal(SubGoal0, SubGoal, !ModeInfo),
         GoalExpr = scope(Reason, SubGoal),
-        mode_checkpoint(exit, "scope", !ModeInfo),
+        mode_checkpoint(exit, "promise_purity scope", !ModeInfo),
         mode_info_set_in_promise_purity_scope(InPPScope, !ModeInfo)
     ).
 
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.397
diff -u -b -r1.397 modes.m
--- compiler/modes.m	16 Aug 2011 03:26:32 -0000	1.397
+++ compiler/modes.m	16 Aug 2011 04:06:46 -0000
@@ -135,6 +135,7 @@
 :- import_module check_hlds.delay_partial_inst.
 :- import_module check_hlds.det_analysis.
 :- import_module check_hlds.inst_match.
+:- import_module check_hlds.mode_debug.
 :- import_module check_hlds.mode_errors.
 :- import_module check_hlds.mode_util.
 :- import_module check_hlds.modecheck_goal.
@@ -637,7 +638,7 @@
         mode_list_get_final_insts(!.ModuleInfo, ArgModes0, ArgFinalInsts0),
 
         modecheck_proc_body(!.ModuleInfo, WhatToCheck, InferModes,
-            Markers, Body0, Body, HeadVars, InstMap0,
+            Markers, PredId, ProcId, Body0, Body, HeadVars, InstMap0,
             ArgFinalInsts0, ArgFinalInsts, !ModeInfo),
 
         mode_info_get_errors(!.ModeInfo, ModeErrors),
@@ -698,16 +699,17 @@
     ).
 
 :- pred modecheck_proc_body(module_info::in, how_to_check_goal::in,
-    bool::in, pred_markers::in, hlds_goal::in, hlds_goal::out,
+    bool::in, pred_markers::in, pred_id::in, proc_id::in,
+    hlds_goal::in, hlds_goal::out,
     list(prog_var)::in, instmap::in, list(mer_inst)::in, list(mer_inst)::out,
     mode_info::in, mode_info::out) is det.
 
 modecheck_proc_body(ModuleInfo, WhatToCheck, InferModes, Markers,
-        Body0, Body, HeadVars, InstMap0, ArgFinalInsts0, ArgFinalInsts,
-        ModeInfo0, ModeInfo) :-
+        PredId, ProcId, Body0, Body, HeadVars, InstMap0,
+        ArgFinalInsts0, ArgFinalInsts, ModeInfo0, ModeInfo) :-
     do_modecheck_proc_body(ModuleInfo, WhatToCheck, InferModes, Markers,
-        Body0, Body1, HeadVars, InstMap0, ArgFinalInsts0, ArgFinalInsts1,
-        ModeInfo0, ModeInfo1),
+        PredId, ProcId, Body0, Body1, HeadVars, InstMap0,
+        ArgFinalInsts0, ArgFinalInsts1, ModeInfo0, ModeInfo1),
     mode_info_get_errors(ModeInfo1, ModeErrors1),
     (
         ModeErrors1 = [],
@@ -733,7 +735,7 @@
             mode_info_set_make_ground_terms_unique(make_ground_terms_unique,
                 ModeInfo0, ModeInfo2),
             do_modecheck_proc_body(ModuleInfo, WhatToCheck, InferModes,
-                Markers, Body0, Body, HeadVars, InstMap0,
+                Markers, PredId, ProcId, Body0, Body, HeadVars, InstMap0,
                 ArgFinalInsts0, ArgFinalInsts, ModeInfo2, ModeInfo)
         ;
             HadFromGroundTerm = did_not_have_from_ground_term_scope,
@@ -746,13 +748,17 @@
     ).
 
 :- pred do_modecheck_proc_body(module_info::in, how_to_check_goal::in,
-    bool::in, pred_markers::in, hlds_goal::in, hlds_goal::out,
-    list(prog_var)::in, instmap::in, list(mer_inst)::in, list(mer_inst)::out,
-    mode_info::in, mode_info::out) is det.
+    bool::in, pred_markers::in, pred_id::in, proc_id::in,
+    hlds_goal::in, hlds_goal::out, list(prog_var)::in, instmap::in,
+    list(mer_inst)::in, list(mer_inst)::out, mode_info::in, mode_info::out)
+    is det.
 
 do_modecheck_proc_body(ModuleInfo, WhatToCheck, InferModes, Markers,
-        Body0, Body, HeadVars, InstMap0, ArgFinalInsts0, ArgFinalInsts,
-        !ModeInfo) :-
+        PredId, ProcId, Body0, Body, HeadVars, InstMap0,
+        ArgFinalInsts0, ArgFinalInsts, !ModeInfo) :-
+    string.format("procedure_%d_%d",
+        [i(pred_id_to_int(PredId)), i(proc_id_to_int(ProcId))],
+        CheckpointMsg),
     (
         InferModes = no,
         check_marker(Markers, marker_mode_check_clauses),
@@ -787,14 +793,15 @@
                 ClausesForm0 = clause_disj(Disjuncts1),
                 Disjuncts2 = flatten_disjs(Disjuncts1),
                 list.map_foldl(
-                    modecheck_clause_disj(HeadVars, InstMap0, ArgFinalInsts0),
+                    modecheck_clause_disj(CheckpointMsg, HeadVars,
+                        InstMap0, ArgFinalInsts0),
                     Disjuncts2, Disjuncts, !ModeInfo),
                 NewGoalExpr = disj(Disjuncts)
             ;
                 ClausesForm0 = clause_switch(SwitchVar, CanFail, Cases1),
                 list.map_foldl(
-                    modecheck_clause_switch(HeadVars, InstMap0,
-                        ArgFinalInsts0, SwitchVar),
+                    modecheck_clause_switch(CheckpointMsg, HeadVars,
+                        InstMap0, ArgFinalInsts0, SwitchVar),
                     Cases1, Cases, !ModeInfo),
                 NewGoalExpr = switch(SwitchVar, CanFail, Cases)
             )
@@ -819,15 +826,16 @@
                     true
                 ),
                 list.map_foldl(
-                    unique_modecheck_clause_disj(HeadVars, InstMap0,
-                        ArgFinalInsts0, Detism, NonLocals, NondetLiveVars0),
+                    unique_modecheck_clause_disj(CheckpointMsg, HeadVars,
+                        InstMap0, ArgFinalInsts0, Detism, NonLocals,
+                        NondetLiveVars0),
                     Disjuncts2, Disjuncts, !ModeInfo),
                 NewGoalExpr = disj(Disjuncts)
             ;
                 ClausesForm0 = clause_switch(SwitchVar, CanFail, Cases1),
                 list.map_foldl(
-                    unique_modecheck_clause_switch(HeadVars, InstMap0,
-                        ArgFinalInsts0, SwitchVar),
+                    unique_modecheck_clause_switch(CheckpointMsg, HeadVars,
+                        InstMap0, ArgFinalInsts0, SwitchVar),
                     Cases1, Cases, !ModeInfo),
                 NewGoalExpr = switch(SwitchVar, CanFail, Cases)
             )
@@ -844,6 +852,7 @@
         ArgFinalInsts = ArgFinalInsts0
     ;
         % Modecheck the procedure body as a single goal.
+        mode_checkpoint(enter, CheckpointMsg, !ModeInfo),
         (
             WhatToCheck = check_modes,
             modecheck_goal(Body0, Body1, !ModeInfo)
@@ -851,6 +860,7 @@
             WhatToCheck = check_unique_modes,
             unique_modes_check_goal(Body0, Body1, !ModeInfo)
         ),
+        mode_checkpoint(exit, CheckpointMsg, !ModeInfo),
 
         % Check that final insts match those specified in the mode declaration.
         modecheck_final_insts(HeadVars, InferModes,
@@ -1017,25 +1027,28 @@
     --->    clause_disj(list(hlds_goal))
     ;       clause_switch(prog_var, can_fail, list(case)).
 
-:- pred modecheck_clause_disj(list(prog_var)::in, instmap::in,
+:- pred modecheck_clause_disj(string::in, list(prog_var)::in, instmap::in,
     list(mer_inst)::in, hlds_goal::in, hlds_goal::out,
     mode_info::in, mode_info::out) is det.
 
-modecheck_clause_disj(HeadVars, InstMap0, ArgFinalInsts0, Disjunct0, Disjunct,
-        !ModeInfo) :-
+modecheck_clause_disj(CheckpointMsg, HeadVars, InstMap0, ArgFinalInsts0,
+        Disjunct0, Disjunct, !ModeInfo) :-
+    mode_checkpoint(enter, CheckpointMsg, !ModeInfo),
     mode_info_set_instmap(InstMap0, !ModeInfo),
     modecheck_goal(Disjunct0, Disjunct1, !ModeInfo),
+    mode_checkpoint(exit, CheckpointMsg, !ModeInfo),
 
     % Check that final insts match those specified in the mode declaration.
     modecheck_final_insts(HeadVars, no, ArgFinalInsts0,
         _ArgFinalInsts, Disjunct1, Disjunct, !ModeInfo).
 
-:- pred modecheck_clause_switch(list(prog_var)::in, instmap::in,
+:- pred modecheck_clause_switch(string::in, list(prog_var)::in, instmap::in,
     list(mer_inst)::in, prog_var::in, case::in, case::out,
     mode_info::in, mode_info::out) is det.
 
-modecheck_clause_switch(HeadVars, InstMap0, ArgFinalInsts0, Var, Case0, Case,
-        !ModeInfo) :-
+modecheck_clause_switch(CheckpointMsg, HeadVars, InstMap0, ArgFinalInsts0,
+        Var, Case0, Case, !ModeInfo) :-
+    mode_checkpoint(enter, CheckpointMsg, !ModeInfo),
     Case0 = case(MainConsId, OtherConsIds, Goal0),
     mode_info_set_instmap(InstMap0, !ModeInfo),
 
@@ -1056,34 +1069,40 @@
 
     % Don't lose the information added by the functor test above.
     fixup_instmap_switch_var(Var, InstMap0, InstMap, Goal1, Goal2),
+    mode_checkpoint(exit, CheckpointMsg, !ModeInfo),
 
     % Check that final insts match those specified in the mode declaration.
     modecheck_final_insts(HeadVars, no, ArgFinalInsts0,
         _ArgFinalInsts, Goal2, Goal, !ModeInfo),
     Case = case(MainConsId, OtherConsIds, Goal).
 
-:- pred unique_modecheck_clause_disj(list(prog_var)::in, instmap::in,
-    list(mer_inst)::in, determinism::in, set_of_progvar::in, bag(prog_var)::in,
-    hlds_goal::in, hlds_goal::out, mode_info::in, mode_info::out) is det.
+:- pred unique_modecheck_clause_disj(string::in, list(prog_var)::in,
+    instmap::in, list(mer_inst)::in, determinism::in, set_of_progvar::in,
+    bag(prog_var)::in, hlds_goal::in, hlds_goal::out,
+    mode_info::in, mode_info::out) is det.
 
-unique_modecheck_clause_disj(HeadVars, InstMap0, ArgFinalInsts0, DisjDetism,
-        DisjNonLocals, NondetLiveVars0, Disjunct0, Disjunct, !ModeInfo) :-
+unique_modecheck_clause_disj(CheckpointMsg, HeadVars, InstMap0, ArgFinalInsts0,
+        DisjDetism, DisjNonLocals, NondetLiveVars0,
+        Disjunct0, Disjunct, !ModeInfo) :-
+    mode_checkpoint(enter, CheckpointMsg, !ModeInfo),
     mode_info_set_instmap(InstMap0, !ModeInfo),
     mode_info_set_nondet_live_vars(NondetLiveVars0, !ModeInfo),
     unique_modes.prepare_for_disjunct(Disjunct0, DisjDetism, DisjNonLocals,
         !ModeInfo),
     unique_modes_check_goal(Disjunct0, Disjunct1, !ModeInfo),
+    mode_checkpoint(exit, CheckpointMsg, !ModeInfo),
 
     % Check that final insts match those specified in the mode declaration.
     modecheck_final_insts(HeadVars, no, ArgFinalInsts0,
         _ArgFinalInsts, Disjunct1, Disjunct, !ModeInfo).
 
-:- pred unique_modecheck_clause_switch(list(prog_var)::in, instmap::in,
-    list(mer_inst)::in, prog_var::in, case::in, case::out,
+:- pred unique_modecheck_clause_switch(string::in, list(prog_var)::in,
+    instmap::in, list(mer_inst)::in, prog_var::in, case::in, case::out,
     mode_info::in, mode_info::out) is det.
 
-unique_modecheck_clause_switch(HeadVars, InstMap0, ArgFinalInsts0, Var,
-        Case0, Case, !ModeInfo) :-
+unique_modecheck_clause_switch(CheckpointMsg, HeadVars, InstMap0,
+        ArgFinalInsts0, Var, Case0, Case, !ModeInfo) :-
+    mode_checkpoint(enter, CheckpointMsg, !ModeInfo),
     Case0 = case(MainConsId, OtherConsIds, Goal0),
     mode_info_set_instmap(InstMap0, !ModeInfo),
 
@@ -1102,6 +1121,7 @@
     % Don't lose the information added by the functor test above.
     mode_info_get_instmap(!.ModeInfo, InstMap),
     fixup_instmap_switch_var(Var, InstMap0, InstMap, Goal1, Goal2),
+    mode_checkpoint(exit, CheckpointMsg, !ModeInfo),
 
     % Check that final insts match those specified in the mode declaration.
     modecheck_final_insts(HeadVars, no, ArgFinalInsts0, _ArgFinalInsts,
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.138
diff -u -b -r1.138 unique_modes.m
--- compiler/unique_modes.m	16 Aug 2011 03:26:34 -0000	1.138
+++ compiler/unique_modes.m	16 Aug 2011 04:04:02 -0000
@@ -304,7 +304,8 @@
             !ModeInfo)
     ;
         GoalExpr0 = scope(Reason0, SubGoal0),
-        unique_modes_check_goal_scope(Reason0, SubGoal0, GoalExpr, !ModeInfo)
+        unique_modes_check_goal_scope(Reason0, SubGoal0, GoalInfo0, GoalExpr,
+            !ModeInfo)
     ;
         GoalExpr0 = shorthand(ShortHand0),
         (
@@ -494,11 +495,28 @@
     mode_checkpoint(exit, "not", !ModeInfo).
 
 :- pred unique_modes_check_goal_scope(scope_reason::in, hlds_goal::in,
-    hlds_goal_expr::out, mode_info::in, mode_info::out) is det.
+    hlds_goal_info::in, hlds_goal_expr::out, mode_info::in, mode_info::out)
+    is det.
 
-unique_modes_check_goal_scope(Reason, SubGoal0, GoalExpr, !ModeInfo) :-
-    mode_checkpoint(enter, "scope", !ModeInfo),
-    ( Reason = from_ground_term(TermVar, from_ground_term_construct) ->
+unique_modes_check_goal_scope(Reason, SubGoal0, GoalInfo0, GoalExpr,
+        !ModeInfo) :-
+    (
+        Reason = trace_goal(_, _, _, _, _),
+        mode_checkpoint(enter, "trace scope", !ModeInfo),
+        mode_info_get_instmap(!.ModeInfo, InstMap0),
+        NonLocals = goal_info_get_nonlocals(GoalInfo0),
+        % We need to lock the non-local variables, to ensure that
+        % the trace goal does not bind them. If it did, then the code
+        % would not be valid with the trace goal disabled.
+        mode_info_lock_vars(var_lock_trace_goal, NonLocals, !ModeInfo),
+        unique_modes_check_goal(SubGoal0, SubGoal, !ModeInfo),
+        mode_info_unlock_vars(var_lock_trace_goal, NonLocals, !ModeInfo),
+        mode_info_set_instmap(InstMap0, !ModeInfo),
+        mode_checkpoint(exit, "trace scope", !ModeInfo),
+        GoalExpr = scope(Reason, SubGoal)
+    ;
+        Reason = from_ground_term(TermVar, from_ground_term_construct),
+        mode_checkpoint(enter, "from_ground_term_construct scope", !ModeInfo),
         mode_info_var_is_live(!.ModeInfo, TermVar, LiveTermVar),
         (
             LiveTermVar = is_live,
@@ -520,12 +538,24 @@
             LiveTermVar = is_dead,
             % The term constructed by the scope is not used anywhere.
             GoalExpr = conj(plain_conj, [])
-        )
+        ),
+        mode_checkpoint(exit, "from_ground_term_construct scope", !ModeInfo)
     ;
+        ( Reason = from_ground_term(_, from_ground_term_deconstruct)
+        ; Reason = from_ground_term(_, from_ground_term_other)
+        ; Reason = exist_quant(_)
+        ; Reason = promise_solutions(_, _)
+        ; Reason = promise_purity(_)
+        ; Reason = require_detism(_)
+        ; Reason = require_complete_switch(_)
+        ; Reason = commit(_)
+        ; Reason = barrier(_)
+        ),
+        mode_checkpoint(enter, "scope", !ModeInfo),
         unique_modes_check_goal(SubGoal0, SubGoal, !ModeInfo),
+        mode_checkpoint(exit, "scope", !ModeInfo),
         GoalExpr = scope(Reason, SubGoal)
-    ),
-    mode_checkpoint(exit, "scope", !ModeInfo).
+    ).
 
 :- pred unique_modes_check_goal_generic_call(generic_call::in,
     list(prog_var)::in, list(mer_mode)::in, determinism::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/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/appengine
cvs diff: Diffing samples/appengine/war
cvs diff: Diffing samples/appengine/war/WEB-INF
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/concurrency
cvs diff: Diffing samples/concurrency/dining_philosophers
cvs diff: Diffing samples/concurrency/midimon
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
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.413
diff -u -b -r1.413 Mmakefile
--- tests/hard_coded/Mmakefile	10 Aug 2011 05:11:57 -0000	1.413
+++ tests/hard_coded/Mmakefile	16 Aug 2011 04:07:23 -0000
@@ -33,6 +33,7 @@
 	compare_spec \
 	comparison \
 	complicated_unify_bug \
+	conditional_trace_scope \
 	constant_prop_1 \
 	constraint \
 	constraint_order \
Index: tests/hard_coded/conditional_trace_scope.exp
===================================================================
RCS file: tests/hard_coded/conditional_trace_scope.exp
diff -N tests/hard_coded/conditional_trace_scope.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/conditional_trace_scope.exp	14 Mar 2011 07:34:01 -0000
@@ -0,0 +1 @@
+X = 43
Index: tests/hard_coded/conditional_trace_scope.m
===================================================================
RCS file: tests/hard_coded/conditional_trace_scope.m
diff -N tests/hard_coded/conditional_trace_scope.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/conditional_trace_scope.m	16 Aug 2011 03:56:11 -0000
@@ -0,0 +1,38 @@
+% vim: ts=4 sw=4 et ft=mercury
+%
+% The test predicate of this test case contains a conditionally enabled
+% trace goal that throws an exception. Both the main and the unique mode
+% checkers normally discard any goals after any erroneous goals, but if
+% the erroneous goal is in a trace scope that may be deleted, they should
+% not do so.
+
+:- module conditional_trace_scope.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+:- import_module list.
+:- import_module require.
+:- import_module string.
+
+main(!IO) :-
+    test(42, Y),
+    io.format("X = %d\n", [i(Y)], !IO).
+
+:- pred test(int::in, int::out) is det.
+
+test(X, Y) :-
+    ( X < 10 ->
+        X = Y
+    ;
+        trace [compiletime(flag("flag_is_not_set"))] (
+            error("error_is_not_thrown")
+        ),
+        Y = X + 1
+    ).
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
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