[GHC] #4042: Order of declarations affects the correctness of reported error.

GHC cvs-ghc at haskell.org
Fri May 7 10:59:46 EDT 2010


#4042: Order of  declarations affects the correctness of reported error.
------------------------------------------------+---------------------------
  Reporter:  ChrisN                             |          Owner:                  
      Type:  bug                                |         Status:  closed          
  Priority:  normal                             |      Milestone:                  
 Component:  Compiler (Parser)                  |        Version:  6.12.2          
Resolution:  fixed                              |       Keywords:                  
Difficulty:                                     |             Os:  Linux           
  Testcase:  rename/should_fail/T4042           |   Architecture:  Unknown/Multiple
   Failure:  Incorrect warning at compile-time  |  
------------------------------------------------+---------------------------
Changes (by simonpj):

 * cc: kfisher@… (added)
  * status:  new => closed
  * resolution:  => fixed
  * testcase:  => rename/should_fail/T4042


Comment:

 Right.  Fixed by
 {{{
 Thu May  6 17:15:23 BST 2010  simonpj at microsoft.com
   * Add a HsExplicitFlag to SpliceDecl, to improve Trac #4042

   The issue here is that

       g :: A -> A
       f
       data A = A

   is treated as if you'd written $(f); that is the call of
   f is a top-level Template Haskell splice.  This patch
   makes sure that we *first* check the -XTemplateHaskellFlag
   and bleat about a parse error if it's off.  Othewise we
   get strange seeing "A is out of scope" errors.

     M ./compiler/hsSyn/HsDecls.lhs -2 +6
     M ./compiler/parser/RdrHsSyn.lhs -2 +2
     M ./compiler/rename/RnExpr.lhs -1 +1
     M ./compiler/rename/RnSource.lhs -1 +12
     M ./compiler/typecheck/TcRnDriver.lhs -3 +3
 }}}
 Now you get
 {{{
 T4042.hs:6:1: Parse error: naked expression at top level
 }}}
 At least that's what happens without `-XTemplateHaskell`. If you have
 Template Haskell on, then you should know about top level splices.

 However maybe the syntax is ''too'' quiet.  The motivation is here
 http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/template-
 haskell.html (last bullet in the Syntax section).  Anyway, it's a bit
 better now.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4042#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list