[GHC] #16175: wrong wording (and possibly wrong location) in parse error message for "do $ bar"

GHC ghc-devs at haskell.org
Sun Jan 13 18:29:25 UTC 2019


#16175: wrong wording (and possibly wrong location) in parse error message for "do
$ bar"
-------------------------------------+-------------------------------------
           Reporter:  j.waldmann     |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.6.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 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
 https://ghc.haskell.org/trac/ghc/ticket/12146

 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?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16175>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list