Fix #15502 by not casting to Int during TH conversion
authorRyan Scott <ryan.gl.scott@gmail.com>
Mon, 27 Aug 2018 12:02:49 +0000 (14:02 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sun, 16 Sep 2018 16:31:14 +0000 (12:31 -0400)
commit8344588e23fc9bb3c1b15e81edd316134c9860ec
treeaaba82e9f620a4e2d019c7ffd092fb38458dc53c
parentceffd7fe3f310cb30fec870f768e8047af309d99
Fix #15502 by not casting to Int during TH conversion

Summary:
When turning an `IntegerL` to an `IntegralLit` during TH
conversion, we were stupidly casting an `Integer` to an `Int` in
order to determine how it should be pretty-printed. Unsurprisingly,
this causes problems when the `Integer` doesn't lie within the bounds
of an `Int`, as demonstrated in #15502.

The fix is simple: don't cast to an `Int`.

Test Plan: make test TEST=T15502

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15502

Differential Revision: https://phabricator.haskell.org/D5089

(cherry picked from commit 7a3cda534d1447c813aa37cdd86e20b8d782cb02)
compiler/basicTypes/BasicTypes.hs
testsuite/tests/th/T15502.hs [new file with mode: 0644]
testsuite/tests/th/T15502.stderr [new file with mode: 0644]
testsuite/tests/th/all.T