[m-rev.] for review: fix singleton variable warning problem

Peter Ross pro at missioncriticalit.com
Fri May 31 17:01:01 AEST 2002


On Fri, May 31, 2002 at 02:21:46PM +1000, Simon Taylor wrote:
> 
> On 30-May-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > Estimated hours taken: 4
> > Branches: main
> > 
> > compiler/make_hlds.m:
> >     Avoid the problem with a variable with a non anonymous name in a
> >     Mercury clause is renamed to an anonymous variable name by
> >     interaction merging in the varset of a pragma foreign_code, and
> >     hence causes spurious warnings.
> 
> Could you try that again please.
> 
> > Index: compiler/make_hlds.m
> > ===================================================================
> > @@ -5644,9 +5644,13 @@
> >  		io__write_string("  in the argument list.\n"),
> >  		io__set_exit_status(1)
> >  	;
> > -		% merge the varsets of the proc and the new pragma_c_code
> > +		% Merge the varsets of the proc and the new foreign_proc.
> > +		% Note that we discard the names of the foreign_proc as
> > +		% this avoids problems with anonymous variables and
> > +		% implementations in Mercury.
> 
> The comment needs to describe what the problem was.
> 
> >  		{
> > -		varset__merge_subst(VarSet0, PVarSet, VarSet1, Subst),
> > +		varset__merge_subst_without_names(VarSet0,
> > +				PVarSet, VarSet1, Subst),
> >  		map__apply_to_list(Args0, Subst, TermArgs),
> >  		term__term_list_to_var_list(TermArgs, Args),
> 
> This is still treating the symptom, not the cause. Why do variables
> in foreign_proc clauses need to be handled differently? Why doesn't
> this problem occur with Mercury clauses?
> 
The problem is that you have a piece of code like in the test case.
The head variables of the foreign_code are (X, _IO0, _IO).  So the
varset for the clause becomes {var(1) -> X, var(2) -> _IO0, var(3) -> _IO}.
Then we process the Mercury clause whose varset is
{var(1) -> HV1, var(2) -> HV2, var(3) -> HV3}.
This varset is merged with that of the clause and we are left with 
{var(1) -> X, var(2) -> _IO0, var(3) -> _IO}.
Now the clause is represented by something like when you use the names
from the new varset, and hence you get warnings.

p(HV1, HV2, HV3) -->
    HV2 = _IO0,
    HV1 = 5,
    _IO = _IO0,
    HV3 = _IO.

In other words a variable with a non anonymous name in a
Mercury clause is renamed to an anonymous variable name by
interaction merging in the varset of a pragma foreign_code, and
hence causes spurious warnings.

To me that says exactly what happens, I can add the example as well.
--------------------------------------------------------------------------
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