[GHC] #13921: LANGUAGE pragma is accepted in module body

The LANGUAGE pragma is a file-header pragma. A file-header pragma must
#13921: LANGUAGE pragma is accepted in module body -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | 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: -------------------------------------+------------------------------------- As pointed out in #13918, the [[https://www.haskell.org/onlinereport/haskell2010/haskellch12.html#x19-19100012.3|Haskell Report]] stipulates that, precede the module keyword in a source file. However, GHC accepts this program, {{{#!hs module Hi where h = {-# LANGUAGE BangPatterns #-} 0 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13921 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

An implementation is not required to respect any pragma, although
#13921: LANGUAGE pragma is accepted in module body -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I suppose it's arguably okay to treat the `LANGUAGE` pragma in this context as unknown and therefore ignore it. From the Report, pragmas that are not recognised by the implementation should be ignored. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13921#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13921: LANGUAGE pragma is accepted in module body -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => low -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13921#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13921: LANGUAGE pragma is accepted in module body -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by svenpanne): I would even go a step further: Syntactically, pragmas are just comments with a special content, so the example in the OP **must** be accepted from a language lawyer POV. It is equivalent (modulo column numbers) to: {{{#!haskell module Hi where h = 0 }}} From a developer POV, a warning would be nice, though. :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13921#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC