[GHC] #9378: Make unknown LANGUAGE pragmas a warning, not an error

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Currently, if I say `{-# LANGUAGE Foo #-}` at the top of my file, it fails to compile. This failure seems unnecessary, especially because any new language feature `Foo` enables will fail to compile later on down the file. Is it possible to have a "stern warning" that is produced even when other parts of the file produce errors? The reason I'm bringing this up is that, when 7.8 came out with its role annotations, users needed CPP in two different places: both to protect the `RoleAnnotations` pragma and to protect the role annotations themselves. This may be unavoidable on the role annotations directly, but I think we can improve the situation around `LANGUAGE` pragmas. Is there a downside to this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Fyi, when you inform Cabal about the used language pragmas via `other- extensions` (which then still need to be declared on a per-module basis via pragmas), Cabal will refuse to build the project if your compiler doesn't provide all those extensions. Moreover, there is tooling to generate the `other-extensions` list automatically from the `.hs` files making up a build-target. So I'm a bit sceptical changing the semantics of `LANGUAGE` to be a mere warning would interact badly with the Cabal tooling. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): This is a good observation, but I don't think it blocks the original request. If I understand correctly, if unrecognized `LANGUAGE` pragmas are a warning, then Cabal might refuse to build something that would, in fact, compile. This doesn't seem deadly. In packages I've released, I've (rightly or wrongly) not specified any extensions in the cabal file. (Except for `TemplateHaskell`, which I understand is necessary for other reasons.) Admittedly, now that you've made me aware of the undocumented `other-extensions` entry, I might change my practice to indeed list the extensions. But, if I'm releasing a package that should compile under multiple GHCs, I would either protect the extension entry in the .cabal file or just omit that particular extension. It is still much easier to put a conditional in one place in a .cabal file than in every source file. Of course, one could list the extension of interest in `default-extensions` and omit it from the files, but then that has poor interaction with GHCi. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Well, then there's the other thing that turning such a pragma into warning is in conflict with the [https://www.haskell.org/onlinereport/haskell2010/haskellch12.html#x19-191000... Haskell 2010 Report] stating explicitly that:
If a Haskell implementation does not recognize or support a particular language feature that a source file requests (or cannot support the combination of language features requested), any attempt to compile or otherwise use that file with that Haskell implementation **must fail with an error**.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): Thanks for finding that reference. I'm a big proponent of adhering to published standards, so that definitely cuts my proposal down a notch. Perhaps we could have a `-fallow-unrecognized-extensions`, or perhaps it's not worth the bother. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Fwiw, I don't see any harm in implementing and documenting an `-fallow- unrecognized-extensions` extension :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * type: bug => feature request Comment: See the function `unsupportedExtnError` in the file `compiler/main/HeaderInfo.hs`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9378: Make unknown LANGUAGE pragmas a warning, not an error -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: wontfix | 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 thomie): * status: new => closed * resolution: => wontfix Comment: Replying to [comment:4 goldfire]:
Perhaps we could have a `-fallow-unrecognized-extensions`, or perhaps it's not worth the bother.
Such a flag wouldn't help with the scenario given in the description, since it would be disabled by default, and CPP would still be necessary. Given that there hasn't been much interest in this ticket, I'm closing as wontfix. Please reopen and change the title if you disagree. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9378#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC