[GHC] #12610: Emit tab warning promptly

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs p = let x = 4 [tab]y = 5 in 12 }}} produces `error: parse error on input ‘y’` and nothing else. The problem is caused by a tab appearing to the user to line up `x` with `y` but actually placing `y` in the wrong column. The user typically will scratch their head and then post a question on StackOverflow. There they'll be told to use `-fwarn-tabs`, but ''that option won't help'' (and it's probably already on) because GHC will exit with a parse error before it gets around to giving the warning. I suspect the solution is probably to emit the tab warning in the lexer, but one of the parsing gurus will probably know better. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Actually, the problem ''seems'' to be that the lexer adds tab warnings to some sort of warning log, and then `GHC.parser` only calls `getMessages` to retrieve a warning log summary when the parse is successful. We should probably change that to get at least some of the warnings in case of an unsuccessful parse. If it's impossible to change the type of `GHC.parser` between minor versions, then we could either add a function with the right type to use for `ghc` proper, or we could temporarily change `GHC.parser` to dump certain warnings into the error bucket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Good catch, that ought to be fixed. I’d say: Do the proper fix first on HEAD, and then think about the form of a possible backport. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.2 => 8.0.3 Comment: I don't think this will happen for 8.0.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dalaing): * owner: => dalaing -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dalaing): It looks like these are the various warnings that can be generated by the parser: If `Opt_WarnTabs` is set: * the tab warnings are collected and summarised If `Opt_WarnUnrecognisedPragmas` is set: * "Unrecognised pragma" If `Opt_WarnAlternativeLayoutRuleTransitional` is set: * "`where' clause at the same depth as implicit layout block" * "`|' at the same depth as implicit layout block" I think it's probably reasonable to print all of the warnings generated during parsing in the event of an unsuccessful parse. The other option would be to print the tab warning and suppress the others. I'm not sure we have enough structure in the warnings at the moment to do anything more fine grained unless we filtered them based on their warning strings. Adding an ADT for the warnings would help with that, and could be a positive step for later, but it's not something we need right now if folks agree that we always want to print all of the warnings on an unsuccessful parse. I'm going to start working on a change that prints warnings on unsuccessful parses (except perhaps for HeaderInfo.getImports, which has a note in it about not logging warning) and see how that goes. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): That sounds pretty reasonable to me. Just make sure you limit the output size however (if at all) it's limited elsewhere. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dalaing): It looks like getting this to work while keeping the ability to run the parser with a pure function might involve modifying the `PFailed` constructor from the `ParseResult` data type. It's not the end of the world, but I figure it's worth mentioning in case folks have objections. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.0.3 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): Right, this is the worry I was talking to you about on IRC. You could instead make the return type of the parser monad `(DynFlags -> [Errs], ParseResult a)` if that is clearer. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: This won't happen for 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: patch Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3584 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dalaing): * status: new => patch * differential: => Phab:D3584 Comment: I'm not 100% sure on where we should be printing these warnings versus ignoring them. I've generally gone with doing whatever happens to the warnings in the case of a successful pass. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12610: Emit tab warning promptly
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: dalaing
Type: bug | Status: patch
Priority: high | Milestone: 8.4.1
Component: Compiler | Version: 8.0.1
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3584
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12610: Emit tab warning promptly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: dalaing Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3584 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12610#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC