[m-rev.] for review: fix bug with any insts in inst_merge
David Overton
dmo at cs.mu.OZ.AU
Fri Sep 14 09:29:10 AEST 2001
On Fri, Sep 14, 2001 at 02:50:53AM +1000, Fergus Henderson wrote:
> On 11-Sep-2001, David Overton <dmo at cs.mu.OZ.AU> wrote:
> > Fix a bug in inst_merge when merging a ground inst with a bound inst
> > containing 'any' insts. Previously,
> >
> > inst_merge(ground, bound(f(..., any, ...)))
> >
> > would return a result of 'any' which is not as accurate as we would
> > like (e.g. this problem occurs often in Mercury code generated by the
> > HAL compiler). To improve this, we pass the type of the variable
> > being merged to inst_merge and when this situation arises we expand
> > 'ground' to 'bound(<functors of type>)' and use this inst in the
> > merge.
>
> That looks fine.
>
> Just a few minor comments:
>
> > Index: compiler/inst_util.m
> > @@ -1425,9 +1419,12 @@
> > ),
> > merge_uniq(UniqA, UniqB, Uniq).
> > inst_merge_3(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB),
> > - ModuleInfo0, abstract_inst(Name, Args), ModuleInfo) :-
> > - inst_list_merge(ArgsA, ArgsB, ModuleInfo0, Args, ModuleInfo).
> > -inst_merge_3(not_reached, Inst, M, Inst, M).
> > + _, ModuleInfo0, abstract_inst(Name, Args), ModuleInfo) :-
> > + MaybeTypes = list__duplicate(list__length(ArgsA), no),
> > + % We don't know the arguments types of an abstract inst.
>
> The comment here should precede the code to which it applies,
> rather than following it.
Done
>
> > Index: compiler/type_util.m
> ...
> > + ->
> > + list__map(pred(T::in, yes(T)::out) is det, Types,
> > + MaybeTypes)
>
> I'd write that using the functional form:
>
> MaybeTypes = list__map(func(T) = yes(T), Types)
Done
>
> > +maybe_get_higher_order_arg_types(MaybeType, Arity, MaybeTypes) :-
> > + (
> > + MaybeType = yes(Type),
> > + type_is_higher_order(Type, _, _, Types)
> > + ->
> > + list__map(pred(T::in, yes(T)::out) is det, Types, MaybeTypes)
> > + ;
> > + list__duplicate(Arity, no, MaybeTypes)
>
> Likewise here.
Done
--
David Overton Department of Computer Science & Software Engineering
PhD Student The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159 http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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