#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 Revisions:

Description

Consider

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 14 months ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 14 months 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 14 months ago by gintas

  • Owner set to gintas

comment:3 Changed 14 months ago by gintas

  • Cc nomeata added
  • difficulty changed from Unknown to Easy (less than 1 hour)
  • Status changed from new to patch

comment:4 Changed 14 months 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 13 months ago by gintas

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

comment:6 Changed 13 months 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 13 months ago by Joachim Breitner <mail@…>

In 55e7ab1210975e6276f3cab3ac0e1f35bcd772f0/ghc:

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

comment:8 Changed 13 months 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 13 months ago by simonpj

  • Priority changed from normal to highest
  • Test Case set to 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!

Simon

comment:10 Changed 13 months ago by nomeata

  • Resolution set to fixed
  • Status changed from patch to closed

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.