[m-rev.] for review: Fix aborts when checking coercions.
Peter Wang
novalazy at gmail.com
Fri Jul 11 11:18:16 AEST 2025
On Thu, 10 Jul 2025 09:46:12 +0200 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>
>
> On Thu, 10 Jul 2025 15:54:37 +1000, Peter Wang <novalazy at gmail.com> wrote:
> > diff --git a/compiler/typecheck_coerce.m b/compiler/typecheck_coerce.m
> > index 6ecfd6e34..e47e0c382 100644
> > --- a/compiler/typecheck_coerce.m
> > +++ b/compiler/typecheck_coerce.m
> > @@ -313,8 +313,12 @@ build_type_param_variance_restrictions_in_ctor_arg_type(TypeTable, CurTypeCtor,
> > type_vars_in_types(ArgTypes, TypeVars),
> > set.insert_list(TypeVars, !InvariantSet)
> > ;
> > - TypeBody = hlds_eqv_type(_),
> > - unexpected($pred, "hlds_eqv_type")
> > + TypeBody = hlds_eqv_type(EqvType0),
> > + hlds_data.get_type_defn_tparams(TypeDefn, TypeParams),
> > + map.from_corresponding_lists(TypeParams, TypeArgs, TSubst),
> > + apply_subst_to_type(TSubst, EqvType0, EqvType),
> > + build_type_param_variance_restrictions_in_ctor_arg_type(TypeTable,
> > + CurTypeCtor, CurTypeParams, EqvType, !InvariantSet)
> > )
> > else
> > unexpected($pred, "undefined type")
>
> Can you please add a comment explaining the purpose of the
> build_type_param_variance_restrictions_in_ctor_arg_type predicate?
> The reason why I didn't tackle this bug myself was mostly the absence
> of info what this predicate was meant to do.
How about this?
+ % Return the set of type parameters of the given TypeCtor that must
+ % remain invariant during type conversion.
+ %
+ % If T (a type parameter in the common base type of a type conversion)
+ % is in the invariant set, then T must be bound to the same type on
+ % both sides of the conversion.
+ %
:- pred build_type_param_variance_restrictions(type_table::in,
type_ctor::in, invariant_set::out) is det.
Peter
More information about the reviews
mailing list