Capture and simplify constraints arising from running typed splices
authorMatthew Pickering <matthewtpickering@gmail.com>
Sun, 3 Feb 2019 11:46:28 +0000 (11:46 +0000)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Sun, 10 Feb 2019 13:35:46 +0000 (08:35 -0500)
commita48753bdbc99cda36890e851950f5b79e1c3b2b2
tree6046bf111b644d492ea21ab3ee499809650e61c6
parent027017fb33923b106765f5a0a6fc000ebe421d40
Capture and simplify constraints arising from running typed splices

This fixes a regression caused by #15471 where splicing in a trivial
program such as `[|| return () ||]` would fail as the dictionary for
`return` would never get bound in the module containing the splice.

Arguably this is symptomatic of a major problem affecting TTH where we
serialise renamed asts and then retype check them. The reference to the
dictionary should be fully determined at the quote site so that splicing
doesn't have to solve any implicits at all. It's a coincidence this
works due to coherence but see #15863 and #15865 for examples where
things do go very wrong.

Fixes #16195
compiler/typecheck/TcSplice.hs
testsuite/tests/th/T16195.hs [new file with mode: 0644]
testsuite/tests/th/T16195A.hs [new file with mode: 0644]
testsuite/tests/th/all.T