[m-rev.] for review: Require subtypes to repeat existential type vars and constraints exactly.

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Nov 13 05:10:49 AEDT 2024


On 2024-07-08 17:46 +10:00 AEDT, "Peter Wang" <novalazy at gmail.com> wrote:
>> > +:- pred build_existq_tvars_mapping(tvar::in, tvar::in,
>> > +    existq_tvar_mapping::in, existq_tvar_mapping::out) is semidet.
>> > +
>> > +build_existq_tvars_mapping(VarA, VarB, !ExistQVarsMapping) :-
>> > +    ( if bimap.insert(VarB, VarA, !ExistQVarsMapping) then
>> > +        true
>> > +    else
>> > +        % The reference manual does not require distinct type variables in a
>> > +        % existential quantifier list of a constructor definition (whether or
>> > +        % not a du type is a subtype). This might be an oversight.
>> 
>> I don't think it "might be"; like you, I think it *is* an oversight. It should be fixed,
>> though probably in a separate diff.
>> 
> 
> Right.

The attached diff documents this restriction.

This is not a breaking change, because the compiler already enforces
this restriction. This is done by through the call chain

- parse_du_type_defn
- parse_maybe_exist_quant_constructors
- parse_maybe_exist_quant_constructors_loop
- parse_maybe_exist_quant_constructor
- parse_and_check_quant_vars

with the last of these predicates reporting an error for any duplicates.

For post-commit review by anyone.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.uev
Type: application/octet-stream
Size: 1396 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20241113/176c12e8/attachment.obj>


More information about the reviews mailing list