[m-dev.] for review: fix existential types bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Oct 25 14:51:17 AEST 1999
On 25-Oct-1999, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > On 25-Oct-1999, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > >
> > > compiler/polymorphism.m:
> > > Add the type-info variables added for the existential
> > > type variables of a constructor to the non-locals of
> > > the construction.
> >
> > Hmm... why doesn't the call to implicitly_quantify_goal
> > in polymorphism__fixup_quantification fix that?
> > (polymorphism__fixup_quantification is called from
> > polymorphism__process_clause.)
>
> implicitly_quantify_goal is only called from
> polymorphism__fixup_quantification if the predicate being
> processed has type variables in the argument types.
> This does not check whether called predicates, functions
> or constructors have type variables in their argument types.
That used to be the case a while back, but since my changes
to add existential types, it should not be true now.
The comment on polymorphism__fixup_quantification says
% If the pred we are processing is a polymorphic predicate,
% or contains polymorphically-typed goals, ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and the code checks whether the type_info_map in the poly_info
is empty. If there are any polymorphically typed variables
in the body of the predicate, then the type_info_map should
be non-empty.
> > > + goal_info_get_nonlocals(GoalInfo0, NonLocals0),
> > > + set__insert_list(NonLocals0, ExtraVars, NonLocals),
> > > + goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
> > > Unify = unify(X0, functor(ConsId, ArgVars), Mode0,
> > > - Unification0, UnifyContext) - GoalInfo0,
> > > + Unification0, UnifyContext) - GoalInfo,
> > > list__append(ExtraGoals, [Unify], GoalList),
> > > conj_list_to_goal(GoalList, GoalInfo0, Goal)
> >
> > Shouldn't that last occurrence of `GoalInfo0' be `GoalInfo'?
>
> No, because the extra type-infos are local to that conjunction.
Are you sure?
What about for e.g.
:- type f ---> some [T] foo(T).
:- pred p(bool, f, io__state, io__state).
:- mode p(in, in, di, uo) is det.
p(Flag, U) -->
(if { Flag = yes, U = foo(X) } then
io__print(X)
else
[]
).
After polymorphism this will be
p(Flag, U) -->
(if { Flag = yes, U = foo(TypeInfo, X) } then
io__print(TypeInfo, X)
else
[]
).
and the scope of TypeInfo is not local to the conjunction.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list