[m-users.] Compiler bug found?

Volker Wysk post at volker-wysk.de
Fri Sep 23 22:26:42 AEST 2022


I found the compiler error's cause: The call of append/3 in
split_to_fragments/4 should be append1, not append. Still, I think the
compiler message is faulty.

Am Freitag, dem 23.09.2022 um 14:22 +0200 schrieb Volker Wysk:
> Hi
> 
> This program segment:
> 
> 
> :- pred split_into_fragments(
>     pred(list(P), list(P), list(P))::
>          pred(in(non_empty_list), out(non_empty_list), out) is det,
>     list(P)::in(non_empty_list),
>     list(list(P))::in,
>     list(list(P))::out(non_empty_list))
> is det.
> 
> split_into_fragments(Pred, Paras@[_|_], Akku, Frags) :-
>     Pred(Paras, Frag, Rest),
>     append(Akku, [Frag], Akku1),
>     (
>         Rest = [],
>         Frags = Akku1
>     ;
>         Rest = [_|_],
>         split_into_fragments(Pred, Rest, Akku1, Frags) % line 333 is here
>     ).
> 
> :- pred append1(list(T), list(T), list(T)).
> :- mode append1(in(I), in(non_empty_list), out(non_empty_list)) is det.
> append1([], Ys, Ys).
> append1([X | Xs], Ys, [X | Zs]) :-
>     append1(Xs, Ys, Zs).
> 
> 
> 
> 
> Causes this compiler error:
> 
> 
> serialiser.m:333: In clause for
> serialiser.m:333:   `split_into_fragments((pred(in((list.non_empty_list)),
> serialiser.m:333:   out((list.non_empty_list)), out) is det),
> serialiser.m:333:   in((list.non_empty_list)), in,
> serialiser.m:333:   out((list.non_empty_list)))':
> serialiser.m:333:   mode error: argument 5 did not get sufficiently
> serialiser.m:333:   instantiated.
> serialiser.m:333:   Final instantiatedness of `Frags' was `ground',
> serialiser.m:333:   expected final instantiatedness was
> serialiser.m:333:     named inst list.non_empty_list
> serialiser.m:333:     which expands to
> serialiser.m:333:       bound(
> serialiser.m:333:         '[|]'(ground, ground)
> serialiser.m:333:       ).
> 
> 
> 
> What irritates me with this error message, is that it says "argument 5", but
> split_into_fragments has only 4 arguments. Looks like a compiler bug to me,
> or isn't it ---?
> 
> 
> Cheers,
> Volker
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20220923/3226c747/attachment.sig>


More information about the users mailing list