[m-rev.] for review: fix from_ground_term bugs

Peter Wang novalazy at gmail.com
Wed Sep 23 11:37:36 AEST 2009


On 2009-09-22, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> For review by Peter Wang.
> 
> Zoltan.
> 
> Fix three bugs with from_ground_term scopes, including Mantis bugs 93 and 94.
> 

> diff -u -b -r1.98 mode_info.m
> --- compiler/mode_info.m	23 Dec 2008 01:37:37 -0000	1.98
> +++ compiler/mode_info.m	21 Sep 2009 11:04:04 -0000
> @@ -409,20 +425,28 @@
...
> +
> +                % Says whether we have ever come across in a from_ground_term
> +                % scope.
> +                msi_had_from_ground_term    :: had_from_ground_term_scope,

across a

> +    % This predicate transforms
> +    %
> +    %   scope(TermVar,
> +    %       conj(plain_conj,
> +    %           X1 = ...
> +    %           X2 = ...
> +    %           ...
> +    %           TermVar = ...
> +    %       )
> +    %   )
> +    %
> +    % into
> +    %
> +    %   conj(plain_conj,
> +    %       scope(TermVar,
> +    %           conj(plain_conj,
> +    %               X1 = ...
> +    %               X2 = ...
> +    %               ...
> +    %               CloneVar = ...
> +    %           )
> +    %       ),
> +    %       builtin.copy(CloneVar, TermVar)
> +    %   )

scope(CloneVar, ...) in the second case.

> +    % We must put the instmaps into the goal_infos of all the subgoals of the
> +    % final GoalExpr we return, since modecheck_goal will not get a chance to
> +    % do so.
> +    mode_info_get_instmap(!.ModeInfo, InstMap0),
> +    instmap_lookup_var(InstMap0, TermVar, TermVarOldInst),
> +    ScopeInstMapDelta =
> +        instmap_delta_from_assoc_list([CloneVar - TermVarOldInst]),
> +    goal_info_set_instmap_delta(ScopeInstMapDelta,
> +        ScopeGoalInfo1, ScopeGoalInfo),
> +
> +    Reason = from_ground_term(CloneVar, from_ground_term_construct),
> +    ScopeGoalExpr = scope(Reason, SubGoal),
> +    ScopeGoal = hlds_goal(ScopeGoalExpr, ScopeGoalInfo),
> +
> +    % We could get a more accurate new inst for TermVar by replacing
> +    % all the "shared" functors in TermVarOldInst with "unique".
> +    % However, this should be good enough. XXX wangp, is this right?
> +    TermVarUniqueInst = ground(unique, none),

I think so, but you're calling builtin.copy so maybe it will end up as `unique'
anyway?

> Index: compiler/quantification.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/quantification.m,v
> retrieving revision 1.135
> diff -u -b -r1.135 quantification.m
> --- compiler/quantification.m	8 Sep 2009 02:43:37 -0000	1.135
> +++ compiler/quantification.m	22 Sep 2009 05:57:11 -0000
> @@ -1588,6 +1679,20 @@
>      goal_expr_vars_both_maybe_lambda(NonLocalsToRecompute, GoalExpr,
>          Set, LambdaSet).
>  
> +    % goal_vars_both_maybe_lambda_and_bi_impl(NonLocalsToRecompute, Goal,
> +    %   NonLambdaSet, LambdaSet):
> +    %
> +    % As goal_vars_both_maybe_lambda, but include all the variables from
> +    % from_groun_term scopes, not just the term variable.

from_ground_term

> Index: compiler/superhomogeneous.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/superhomogeneous.m,v
> retrieving revision 1.35
> diff -u -b -r1.35 superhomogeneous.m
> --- compiler/superhomogeneous.m	8 Sep 2009 02:43:39 -0000	1.35
> +++ compiler/superhomogeneous.m	21 Sep 2009 07:26:41 -0000
> @@ -431,8 +431,10 @@
>              GoalExpr = scope(from_ground_term(LHSVar, Kind), SubGoal),
>              Goal = hlds_goal(GoalExpr, GoalInfo)
>          ;
> -            unexpected(this_file,
> -                "do_unravel_unification: from_ground_term not conj")
> +            % This can happen if we unravel large ground term that happens to

unravel a large

You forgot to cvs add the new test cases.

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