[nhc-bugs] nhc98 rejects legal rebinding
Simon Marlow
simonmar@microsoft.com
Tue, 27 May 2003 11:18:39 +0100
Malcolm writes:=20
> However, I do not propose to fix this bug in nhc98. The example
> you give is extremely likely to be a programmer's mistake, so in
> my opinion the error message from the compiler is more useful than
> the strange runtime behaviour that might otherwise occur. When the
> rebinding is deliberate, it is easy for the author to find a different
> way of coding the intended semantics.
While the behaviour might arguably be wrong, I believe it's more
important to stick to the letter of the Haskell 98 spec, at least so
that Haskell 98 compilers are compatible with each other. By all means
emit a warning in this case (GHC does if you add -fwarn-name-shadowing),
but it shouldn't be an error. =20
Besides, it's inconsistent: I'm allowed to shadow 'f', but not 'x'.
This is allowed:
> module Rebind where
> f x =3D x
> where
> f =3D True
Cheers,
Simon