This error is raised in TcErrors.getSkolemInfo called from TcErrors.mkHoleError. Quick look at the code tells me that "implication constraints" are expected to be non-empty but they are. Are implication constraints things that come in the contexts, ie. everything before a =>? Why are they expected to be non-empty?
The problem seems to be that the quoted expression [|| _x ||] will introduce a hole constraint of the form _x :: a when spliced, but that the error will be reported outside of the implication introduced by the signature. When checking the following program:
m :: am = _x
simplifyTop will report that it's found an unsolved wanted constraint of the form forall (a :: *). () => _x :: a. However, when checking the original program, simplifyTop is called from a different path (tcTopSpliceExpr), and reports the wanted constraint as being of the form _x :: a. As it lacks the context of the binding for a, it falls through to the base case of getSkolemInfo, which causes the panic.
At this point, I'm not sure what the right path forward is. Should tcTopSpliceExpr be using simplifyTop, or is there just some additional context needed to be setup before that call?
So in f64f7c36, we added a test case for this that was marked as expect_broken. However, that program now loops infinitely on GHC HEAD!
$ inplace/bin/ghc-stage2 --interactiveGHCi, version 8.5.20180305: http://www.haskell.org/ghc/ :? for helpLoaded GHCi configuration from /home/rgscott/.ghciλ> :set -XTemplateHaskellλ> m :: a -> a; m x = $$([||_||]) -- Loops infinitely^CInterrupted.
Should we disable the test case entirely in the meantime?
A correction to ticket:10946#comment:150039—it doesn't loop infinitely, but it does take a full five minutes to complete that test case on my machine. Still, that's quite severe—we should find out what caused this to regress.
RyanGlScott: It seems like what's happening is that since the variable has no constraints on it at all, then it's matching everything in scope (including everything in scope in TemplateHaskell), and then doing the subsumption graph sorting on that, which takes a very long time. I'll give it some thought, but it seems like the right way to go would be to not try to find valid substitutions for this too general case.