Inconsistent querying of DumpFlags in DynFlags and Logger
During the refactoring we'd like to replace calls to dopt
with calls to logHasDumpFlag
in order to eliminate DynFlag
values from the various components.
But we cannot do this easily as there is an inconsistency regarding how we query DumpFlag
s from DynFlags
and Logger
: In particular, the results for verbosity >= 4 of the two aforementioned functions differ for some flags.
For example, changing the definition of GHC.Core.Opt.Monad.nop
to
nop :: a -> CoreIOEnv (a, CoreWriter)
nop x = do
r <- getEnv
dflags <- hsc_dflags . cr_hsc_env <$> getEnv
let dflags_opt = dopt Opt_D_dump_simpl_stats dflags
logger <- hsc_logger . cr_hsc_env <$> getEnv
let logger_opt = logHasDumpFlag logger Opt_D_dump_simpl_stats
when (dflags_opt /= logger_opt) $
panic $ "Inconsistent -ddump-simpl-stats:"
++ " dflags=" ++ show dflags_opt
++ " logger=" ++ show logger_opt
return (x, emptyWriter $ (hsc_dflags . cr_hsc_env) r)
results in a failure of T20218:
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.5.20220714:
Inconsistent -ddump-simpl-stats: dflags=True logger=False