RE: [nhc-bugs] nhc98 rejects legal rebinding

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

"Simon Marlow"
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.
OK, you have persuaded me. The bug is fixed in CVS, and here is the patch. Regards, Malcolm Index: src/compiler98/Rename.hs =================================================================== RCS file: /home/cvs/root/nhc98/src/compiler98/Rename.hs,v retrieving revision 1.28 diff -u -r1.28 Rename.hs --- src/compiler98/Rename.hs 12 Nov 2002 11:56:51 -0000 1.28 +++ src/compiler98/Rename.hs 27 May 2003 10:54:53 -0000 @@ -459,12 +459,14 @@ let decls = groupFun decls' in pushScope >>> mapS0 (bindPat Var) pats >>> + pushScope >>> bindDecls decls >>> renameDecls decls >>>= \newdecls -> -- do first, to get infix right unitS Fun =>>> mapS renameExp pats =>>> renameRhs rhs =>>> unitS newdecls >>> + popScope >>> popScope
participants (2)
-
Malcolm Wallace
-
Simon Marlow