Put the `ev_binds` of main function inside `runMainIO`
authorHE, Tao <sighingnow@gmail.com>
Sun, 27 May 2018 15:48:20 +0000 (11:48 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 30 May 2018 14:02:10 +0000 (10:02 -0400)
commit49e423e9940a9122a4a417cfc7580b9984fb49eb
tree8906639676278962a50695921b21758627126d0e
parentc65159dcf401d36e8920f43fec300264533642b9
Put the `ev_binds` of main function inside `runMainIO`

This ensures that the deferred type error can be emitted correctly.

For `main` function in `Main` module, we have

    :Main.main = GHC.TopHandler.runMainIO main

When the type of `main` is not `IO t` and the
`-fdefer-type-errors` is enabled, the `ev_binds`
of `main` function will contain deferred type
errors.

Previously, the `ev_binds` are bound to `runMainIO main`,
rather than `main`, the type error exception at runtime
cannot be handled properly. See Trac #13838.

This patch fix that.

Test Plan: make test TEST="T13838"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13838

Differential Revision: https://phabricator.haskell.org/D4708
compiler/typecheck/TcRnDriver.hs
testsuite/tests/typecheck/should_run/T13838.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T13838.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_run/all.T