[GHC] #10662: GHC warning shows technical summary of AST instead of the user's code

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.2-rc2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- I got a warning for some code I wrote; {{{#!hs forkIO (....) }}} Naturally GHC warns me that I'm throwing away the result, and should write like this; {{{#!hs _ <- forkIO (...) }}} However, the warning is expressed in a somewhat confusing way, not sure this is intentional. {{{ examples/route_guide_client.hs:84:5: Warning: A do-notation statement discarded a result of type ‘ThreadId’ Suppress this warning by saying ‘_ <- ($) forkIO let AbsBinds [] [] {Exports: [go <= go <>] Exported types: go :: [L.ByteString] -> IO () [LclId, Str=DmdType] Binds: go acc = ...} in go []’ or by using the flag -fno-warn-unused-do-bind }}} I find it confusing that the warning mentions AbsBinds, exports and types. I'd expect a snippet of my code in the warning. However, doesn't look like this is a (recent) regression. The same happens GHC 7.8.4 and 7.10.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Quite right! Reason: this message is generated by the desugarer, which only has typechecked code to print. Solution: when printing typechecked code, suppress details generated by the type checker itself. Details: * Sometimes we want to see those details, certainly during compiler debugging. And just conceivably for savvy users. So we need a flag to control it. * Quite a lot of supression goes on already. Example: `pprHsWrapper` uses `-dppr-debug` to control whether a `HsWrapper` get printed. But the `-dppr-debug` flag is a pretty low level thing that controls a lot of other debug-printing stuff too. * Nowadays we have `-fprint-explicit-foralls` and `-fprint-explicit- kinds`, so it might be better to add a new flat `-fprint-evidence` (or something) which shows you the extra evidence generated by the type checker. Nothing hard here, if someone would like to take it on. I can advise. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * milestone: 7.10.2 => 7.12.1 Comment: kolmodin: can you please update your example to a working test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by kolmodin: Old description:
I got a warning for some code I wrote;
{{{#!hs forkIO (....) }}}
Naturally GHC warns me that I'm throwing away the result, and should write like this;
{{{#!hs _ <- forkIO (...) }}}
However, the warning is expressed in a somewhat confusing way, not sure this is intentional.
{{{ examples/route_guide_client.hs:84:5: Warning: A do-notation statement discarded a result of type ‘ThreadId’ Suppress this warning by saying ‘_ <- ($) forkIO let AbsBinds [] [] {Exports: [go <= go <>] Exported types: go :: [L.ByteString] -> IO () [LclId, Str=DmdType] Binds: go acc = ...} in go []’ or by using the flag -fno-warn-unused-do-bind
}}}
I find it confusing that the warning mentions AbsBinds, exports and types. I'd expect a snippet of my code in the warning.
However, doesn't look like this is a (recent) regression. The same happens GHC 7.8.4 and 7.10.1.
New description: Have a look at this code and the warning it generates; {{{#!hs -- T10662.hs main :: IO () main = do return $ let a = "hello" in a return () }}} We compile it with {{{ghc --make -Wall T10662.hs}}} {{{ [1 of 1] Compiling Main ( T10662.hs, T10662.o ) T10662.hs:3:3: Warning: A do-notation statement discarded a result of type ‘[Char]’ Suppress this warning by saying ‘_ <- ($) return let AbsBinds [] [] {Exports: [a <= a <>] Exported types: a :: [Char] [LclId, Str=DmdType] Binds: a = "hello"} in a’ or by using the flag -fno-warn-unused-do-bind Linking T10662 ... $ }}} Naturally GHC warns me that I'm throwing away the result, and should write like this; {{{#!hs main :: IO () main = do _ <- return $ let a = "hello" in a return () }}} I find it confusing that the warning mentions AbsBinds, exports and types. I'd expect a snippet of my code in the warning. It doesn't look like this is a (recent) regression. The same happens GHC 7.8.4 and 7.10.1. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by kolmodin): * Attachment "T10662.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => newcomer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Solution: when printing typechecked code, suppress details generated by
#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: newcomer 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 ak3n): Replying to [comment:1 simonpj]: the type checker itself. Excuse me, but how to suppress details? Is there a function for this? I found a warning generation function [https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/deSugar/DsExpr.hs#L100... badMonadBind]. On which step do we need to suppress them ― `HsExpr` or `SDoc`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: newcomer 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 simonpj): Mostly it's a matter of not-printing the stuff added by the typechecker. E.g. not printing the `HsWrap` constructor in `HsExpr`; that is already suppressed (and sadly there is no way to display it even when debugging). But currently we do print the `AbsBinds` constructor in `HsBinds`. Probably we shouldn't unless some flag `-fprint-typechecker-elaboration` is on. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: newcomer 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 ak3n): * owner: => ak3n -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1625 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ak3n): * differential: => Phab:D1625 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10662: GHC warning shows technical summary of AST instead of the user's code
-------------------------------------+-------------------------------------
Reporter: kolmodin | Owner: ak3n
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 7.10.2-rc2
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1625
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10662: GHC warning shows technical summary of AST instead of the user's code -------------------------------------+------------------------------------- Reporter: kolmodin | Owner: ak3n Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2-rc2 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1625 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10662#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC