wrong wording (and possibly wrong location) in parse error message for "do $ bar"
Not a bug, as GHC correctly rejects an invalid program. Still -
Prelude> foo x = do $ bar ; return ()
<interactive>:1:20: error:
Parse error: module header, import declaration
or top-level declaration expected.
Of the three suggestions, only "top-level declaration" can actually happen here (as this also happens deep inside a module).
For reference,
- ghc-7.10 : "parse error on input ‘=’"
- ghc-8.0 : "naked expression at top level"
- ghc-8.2 and later: as above
I think the wording was introduced with #12146 (closed)
Anyway one could also think that the actual error happened earlier, since after removing "return ()" as suggested by the error message, we get
Prelude> foo x = do $ bar
<interactive>:1:9: error: Empty 'do' block
so GHC could also use this as the original error message? By putting "; return ()" at the end, the 'do' block does not become non-empty?
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |