Opened 2 years ago

Last modified 23 months ago

#11306 infoneeded bug

Do not generate warning in `do` when result is of type `Void`.

Reported by: diatchki Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

GHC generates warnings when do notation statements discard their result, without an explicit _ <- , unless the discarded result is of type ().

Another type which is used to indicate "no result", is Void from Data.Void. There are no meaningful values of this type, so we should also skip the warnings for such situations.

Here is an example:

import Data.Void

f :: IO Void
f = undefined

main :: IO ()
main = do f
          return ()

GHC output:

test.hs:7:11: Warning:
    A do-notation statement discarded a result of type ‘Void’
    Suppress this warning by saying ‘_ <- f’
    or by using the flag -fno-warn-unused-do-bind

Change History (3)

comment:1 Changed 2 years ago by rwbarton

I'm not a fan of this warning in the first place, but if anything, I would think it is most important to warn when the discarded value is of type Void, since that typically indicates that the following code is unreachable...

comment:2 in reply to:  1 Changed 23 months ago by thomie

Type of failure: None/UnknownIncorrect warning at compile-time

Won't fix?

comment:3 Changed 23 months ago by goldfire

Status: newinfoneeded

Iavor, do you have an example illustrating your need here? I agree with comment:1.

Note: See TracTickets for help on using tickets.