[m-users.] "operator precedence error" - Mercury bug?

Julien Fischer jfischer at opturion.com
Sat Oct 12 20:00:02 AEDT 2019


Hi Volker,

On Sat, 12 Oct 2019, Volker Wysk wrote:

> This simple module won't compile:
>
> :- module test1.
> :- interface.
> :- import_module char.
> :- pred f(char::in) is semidet.
>
> :- implementation.
>
> f(A) :-
>    A = '/'.

You need to escape that using parentheses.

    f(A) :-
       A = ('/').

Otherwise the compiler will treat that as the '/' operator.
(Mercury doesn't have a specific syntax for character literalsm, they're
just atoms.)

...

> The error does NOT occur when you substitute the '/' for something
> different, for instance 'x'.

Try it with '=' or something else that appears in the operator table.
('x' is not an operator.)

> To me this looks like a Mercury bug.

It's not a bug, just residual Prolog behaviour.

Julien.


More information about the users mailing list