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

GHC ghc-devs at haskell.org
Tue Jul 21 17:06:46 UTC 2015


#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


More information about the ghc-tickets mailing list