Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid printing newlines when processing some type default warnings #2001

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cryptol-saw-core/src/Verifier/SAW/CryptolEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -771,16 +771,21 @@ defaultEvalOpts = E.EvalOpts quietLogger E.defaultPPOpts

moduleCmdResult :: M.ModuleRes a -> IO (a, ME.ModuleEnv)
moduleCmdResult (res, ws) = do
mapM_ (print . pp) (map suppressDefaulting ws)
mapM_ (print . pp) (concatMap suppressDefaulting ws)
case res of
Right (a, me) -> return (a, me)
Left err -> fail $ "Cryptol error:\n" ++ show (pp err) -- X.throwIO (ModuleSystemError err)
where
suppressDefaulting :: MM.ModuleWarning -> MM.ModuleWarning
-- If all warnings are about type defaults, pretend there are no warnings at
-- all to avoid displaying an empty warning container.
suppressDefaulting :: MM.ModuleWarning -> [MM.ModuleWarning]
suppressDefaulting w =
case w of
MM.TypeCheckWarnings nm xs -> MM.TypeCheckWarnings nm (filter (notDefaulting . snd) xs)
MM.RenamerWarnings xs -> MM.RenamerWarnings xs
MM.RenamerWarnings xs -> [MM.RenamerWarnings xs]
MM.TypeCheckWarnings nm xs ->
case filter (notDefaulting . snd) xs of
[] -> []
xs' -> [MM.TypeCheckWarnings nm xs']

notDefaulting :: TE.Warning -> Bool
notDefaulting (TE.DefaultingTo {}) = False
Expand Down
Loading