Opened 3 years ago

Closed 3 years ago

#9086 closed bug (fixed)

main :: IO Int does different things with runghc and when compiled

Reported by: nh2 Owned by: gintas
Priority: highest Milestone: 7.10.1
Component: Compiler Version: 7.8.2
Keywords: Cc: mail@…, nomeata
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case: ghci/scripts/T9086b, ghc-e/should_run/T9086
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



main :: IO Int
main = return 1

This does different things when compiled and when run with runghc/runhaskell (it prints an extra 1 with the latter).

For practical purposes, I think it is beneficial if either of the two ways to run a Haskell program have the same output.

Or did somebody intend this to happen?

Attachments (1)

0001-Do-not-print-the-result-of-main-after-invoking-main-.patch (4.0 KB) - added by gintas 3 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 3 years ago by nomeata

Seems to be a left-over from how commands are handled in GHCi, where the result of an IO action is printed (if it has Show and is not (), it seems).

comment:2 Changed 3 years ago by gintas

Owner: set to gintas

comment:3 Changed 3 years ago by gintas

Cc: nomeata added
difficulty: UnknownEasy (less than 1 hour)
Status: newpatch

comment:4 Changed 3 years ago by nomeata

Thanks for the patch!

It is common to comment when you change the status of the ticket, something like “I worked on this and here is the result. From my point of view, it is good to go. Can someone review and push it” and possibly more (e.g. whether it was hard or easy, whether you like the result or not). A simple status change may be overlooked.

Besides that, the patch (which has a sufficient comment and a test case) looks good from my pov. Unless someone complains I’ll push it soon.

comment:5 Changed 3 years ago by gintas

<friendly ping> Is there anything keeping this patch from being applied?

comment:6 Changed 3 years ago by thoughtpolice

No, I just haven't gotten to the outstanding patch queue. It's on my radar, don't worry.

comment:7 Changed 3 years ago by Joachim Breitner <mail@…>

In 55e7ab1210975e6276f3cab3ac0e1f35bcd772f0/ghc:

Do not print the result of 'main' after invoking ':main' (fixes #9086).

comment:8 Changed 3 years ago by nomeata

Sorry, I promised to push it but then it slipped my mind. Just validated and pushed.

Congrats, Gintautas, for your first contribution to GHC!

comment:9 Changed 3 years ago by simonpj

Priority: normalhighest
Test Case: ghci/scripts/T9086b, ghc-e/should_run/T9086

So, can we close this ticket? It looks as if everyone thinks it's done. I added the test cases to the ticket description.

I'll make it highest priority so we don't forget to close it!


comment:10 Changed 3 years ago by nomeata

Resolution: fixed
Status: patchclosed

Eh, yes, guess my habit of closing stuff with fixes #n in the commit message came through. Sorry.

Note: See TracTickets for help on using tickets.