[GHC] #7791: Bad error message when strictness annotations are used without BangPatterns pragma

#7791: Bad error message when strictness annotations are used without BangPatterns pragma ----------------------------------------------+----------------------------- Reporter: manzyuk | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.4.1 | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: Incorrect warning at compile-time | Blockedby: Blocking: | Related: ----------------------------------------------+----------------------------- Loading the program {{{ powers n = go 1 where go !k = k : go (k * n) }}} into GHCi results in an error: {{{ *Main> :load "/home/manzyuk/tmp/example.hs" [1 of 1] Compiling Main ( /home/manzyuk/tmp/example.hs, interpreted ) /home/manzyuk/tmp/example.hs:1:12: Not in scope: `go' Failed, modules loaded: none. }}} The error message is plain wrong. The problem is fixed by enabling {{{BangPatterns}}} pragma. It would be nice if GHC could suggest that like it does in many other similar cases. {{{ $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.4.1 $ uname -a Linux paddy 2.6.32-45-generic #104-Ubuntu SMP Tue Feb 19 21:20:09 UTC 2013 x86_64 GNU/Linux }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7791 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7791: Bad error message when strictness annotations are used without BangPatterns pragma ----------------------------------------------+----------------------------- Reporter: manzyuk | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.4.1 | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: Incorrect warning at compile-time | Blockedby: Blocking: | Related: ----------------------------------------------+----------------------------- Comment(by monoidal): The error message is correct, since without extensions, the declaration `go ! k = ...` defines an operator called `!` (analogously to `go * k = ...`) and therefore `go` is out of scope in line 1. You can get a nice suggestion if you write `go (!k) = ...` or `go !k !l = ...`. It's hard to expect GHC to deduce from context whether a syntactically-correct `go ! k = ...` was meant to be something different. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7791#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7791: Bad error message when strictness annotations are used without BangPatterns pragma ----------------------------------------------+----------------------------- Reporter: manzyuk | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.4.1 | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: Incorrect warning at compile-time | Blockedby: Blocking: | Related: ----------------------------------------------+----------------------------- Comment(by manzyuk): Thanks for the clarification, this makes sense. I guessed I assumed {{{go !k}}} and {{{go ! k}}} were parsed differently. I'm not convinced that GHC can't detect this situation, but it's probably a corner case that is not worth the added complexity. Please feel free to resolve the ticket. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7791#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7791: Bad error message when strictness annotations are used without BangPatterns pragma ------------------------------------------------+--------------------------- Reporter: manzyuk | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.4.1 Resolution: invalid | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: Incorrect warning at compile-time | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ------------------------------------------------+--------------------------- Changes (by simonpj): * status: new => closed * difficulty: => Unknown * resolution: => invalid Comment: Yes, the trouble is that {{{ go !k = go + k }}} really is a valid definition in Haskell 98, and there is not much we can do about that. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7791#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC