
Malcolm writes:
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. Besides, it's inconsistent: I'm allowed to shadow 'f', but not 'x'. This is allowed:
module Rebind where f x = x where f = True
Cheers, Simon