Warning on pattern synonyms in ghci
Defining and using a pattern synonym in ghci shows a warning in the development version
ghci> :set -XPatternSynonyms
ghci> pattern P = True
ghci> P
WARNING: file compiler/GHC/Core/Opt/Simplify/Env.hs, line 686
$bP
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Driver/Ppr.hs:137:29 in ghc:GHC.Driver.Ppr
warnPprTrace, called at compiler/GHC/Core/Opt/Simplify/Env.hs:686:31 in ghc:GHC.Core.Opt.Simplify.Env
The warning comes from
refineFromInScope :: InScopeSet -> Var -> Var
refineFromInScope in_scope v
| isLocalId v = case lookupInScope in_scope v of
Just v' -> v'
Nothing -> WARN( True, ppr v ) v -- This is an error!
| otherwise = v
I have checked that if this WARN is changed to a panic, there are two testsuite failures and both concern defining a pattern synonym in ghci https://gitlab.haskell.org/tweag/ghc/-/jobs/525160. Somehow the in-scope set does not contain the builder and the matcher in that case.