Fail instead of panic-ing when qAddTopDecls has conversion error
authorMichael Sloan <mgsloan@gmail.com>
Thu, 26 Jul 2018 21:18:22 +0000 (17:18 -0400)
committerBen Gamari <ben@smart-cactus.org>
Fri, 27 Jul 2018 15:40:43 +0000 (11:40 -0400)
commit774f366ebe58023fc50ba346894227b14816fe67
treea2d37336c1d5c609d4e1d4f083d489aa85d18e28
parent13d40ff65b4171c4f0adac10577667d05074441a
Fail instead of panic-ing when qAddTopDecls has conversion error

See https://ghc.haskell.org/trac/ghc/ticket/14627 for an example where
GHC panics when using qAddTopDecls on [d| f = Bool |]. Instead, it
should be a normal error message, and that's what this change is for. It
does not entirely resolve Trac#14627, since "Illegal variable name:
'bool'" isn't a very good error for this cirumstance.

Test Plan: Manually tested.

Reviewers: goldfire, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4914
compiler/typecheck/TcSplice.hs
testsuite/tests/th/TH_invalid_add_top_decl.hs [new file with mode: 0644]
testsuite/tests/th/TH_invalid_add_top_decl.stderr [new file with mode: 0644]
testsuite/tests/th/all.T