[HsToken on TypArg]: compiler panic in Simplify.addEvals
since the HsToken on TypArg commit landed a problem has emerged with this line of code in hlint. in essence the code exercised is,
isKindTyApp :: LHsType GhcPs -> Bool
isKindTyApp = \case (L _ HsAppKindTy{}) -> True; _ -> False
hasS :: (Data x, Data a) => (a -> Bool) -> x -> Bool
hasS test = any test . universeBi
used :: Extension -> Located (HsModule GhcPs) -> Bool
used TypeApplications = hasS isTypeApp ||^ hasS isKindTyApp
...
it manifests as
[44 of 60] Compiling Hint.Extensions [Source file changed]
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.4.4:
Simplify.addEvals
HsAppKindTy
[ds3_ij8Q, ds4_ij8R, ds5_ij8S]
[NotMarkedStrict, NotMarkedStrict, MarkedStrict,
NotMarkedStrict] (length = 4)
[XAppKindTy pass_ifRh, LHsType pass_ifRh, LHsToken "@" pass_ifRh,
LHsKind pass_ifRh] (length = 4)
[, , !,] (length = 4)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:182:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify.hs:3186:16 in ghc:GHC.Core.Opt.Simplify
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
reproduction is a bit flaky. i think it's version independent (i'm mostly doing 9.4.4) but i can't say for sure without more testing.
i'm sorry (!) that i haven't a better (self contained repro) to give right now am not providing a means to repro but i hope there's enough of a clue here to get one write a small ghc-api standalone program that panics in the same way. i figured you'd want to know about this sooner rather than later. for now i'm just blocking it out in Hlint - checking for kind application to determine if TypeApplications
is "used" is a >= 9.6.1 feature anyway.
cc @ndmitchell