[m-rev.] [PATCH] Fix writing of coerce casts in .opt files.

Peter Wang novalazy at gmail.com
Wed Feb 16 17:31:56 AEDT 2022


On Wed, 16 Feb 2022 17:20:08 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> 2022-02-16 16:13 GMT+11:00 "Peter Wang" <novalazy at gmail.com>:
> >      ;
> >          GenericCall = cast(CastType),
> > -        CastTypeString = cast_type_to_string(CastType),
> > +        ( if CastType = subtype_coerce then
> > +            % We must produce valid Mercury code for coerce casts that are
> > +            % written to .opt files.
> > +            CastTypeString = "coerce"
> > +        else
> > +            CastTypeString = cast_type_to_string(CastType)
> > +        ),
> 
> This should be a switch on CastType.

Done.

> > --- /dev/null
> > +++ b/tests/hard_coded/coerce_opt.exp
> > @@ -0,0 +1,4 @@
> > +coerce_opt_2.non_empty_list(int)
> > +[1, 2, 3]
> > +list.list(int)
> > +[1, 2, 3]
> 
> Doesn't the source file print the list.list
> *before* the non_empty_list? How come
> the .exp file has them in the reverse order?

The .exp file is correct. Xs has type non_empty_list(int).

Peter


More information about the reviews mailing list