[m-rev.] Bug found
Zoltan Somogyi
zoltan.somogyi at runbox.com
Wed Oct 12 05:07:57 AEDT 2022
On Tue, 11 Oct 2022 19:30:47 +0200, Volker Wysk <post at volker-wysk.de> wrote:
> The following program causes a compiler error. This happens only when its
> name is "impure". The compiler doesn't like the "impure" module name. The
> error can be triggered with a "program" that consists of nothing but the
> module declaration.
>
>
> :- module impure.
That is not a compiler bug; that is an incorrect program. It is the same
kind of bug as naming a C function "if", and then expecting
the C compiler to interpret "if(42); as a function call, rather than
as an if-then-else.
The word "impure" is a Mercury operator. You cannot use
operators as the name of anything without telling the compiler
"I want to use this operator as it weren't an operator",
which you do by putting parentheses around it.
The compiler *does* accept ":- module (impure).".
Actually, my opinion is that Mercury should not allow
what are effectively Mercury's keywords (or as close
to keywords as Mercury has, which is not very close)
to be used in any other way. but this is one piece of baggage
that Mercury inherited from Prolog.
Zoltan.
More information about the reviews
mailing list