GHC panic: NoFlexi
The following module contains a type error, but instead of reporting it, GHC panics. This occurs with GHC versions 9.2 up to and including HEAD (2025-09-30 at 9c304ec00750b69acb854cd47e50bda0c34ea543); GHC before 9.2 seems to be fine.
```hs
{-# LANGUAGE PatternSynonyms, ViewPatterns #-}
-- prefixed :: String -> String -> Maybe String -- (1a)
-- prefixed [] s = Just s
prefixed (p:ps) (s:ss) | p == s = prefixed ps ss -- (2a)
-- prefixed (p:ps) (s:ss) = prefixed ps ss -- (2b)
-- prefixed _ _ = Nothing
-- prefixed2 :: Eq a => ([a], [a]) -> Maybe [a] -- (1b)
prefixed2 = uncurry prefixed
-- pattern Secured :: (String, String) -> (String, String) -- (1c)
pattern Secured x <- (prefixed2 -> Just x) -- (3a)
-- foo (prefixed2 -> Just x) = x -- (3b)
```
Playground link: https://play.haskell.org/saved/dEntFxcz
This is likely not fully minimised. However:
1. Adding a type signature, either (1a), (1b) or (1c), avoids the panic. (The definition of `prefixed2` implies that the `x` in `Secured` ought to be `String`; usage of `Secured` (in now-elided code; apologies) implies that `x` ought to be `(String, String)`. Declaring either with a type signature avoids the panic; the panic only occurs when no type signature is given at all.)
2. Removing the `p == s` guard (and hence, presumably, eliding an `Eq` constraint) avoids the panic.
3. Replacing the pattern synonym (3a) with a normal function (3b) also avoids the panic.
4. Inlining `prefixed2` into `Secured` also avoids the panic!
Original code by `[exa]` in `#haskell` on libera.chat.
Related by keyword search: #21479
## Environment
* GHC version used: 9.2, 9.4, 9.6, 9.8, 9.10, 9.12, HEAD (2025-09-30 at 9c304ec00750b69acb854cd47e50bda0c34ea543)
issue