[Git][ghc/ghc][master] tc: discard warnings in tcUserStmt Plan C
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 585d7450 by Luite Stegeman at 2026-04-11T02:17:13-04:00 tc: discard warnings in tcUserStmt Plan C We typecheck let_stmt twice, but we don't want the warnings twice! see #26233 - - - - - 5 changed files: - compiler/GHC/Tc/Module.hs - + testsuite/tests/ghci/scripts/T26233.script - + testsuite/tests/ghci/scripts/T26233.stderr - + testsuite/tests/ghci/scripts/T26233.stdout - testsuite/tests/ghci/scripts/all.T Changes: ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2367,8 +2367,9 @@ tcUserStmt (L loc (BodyStmt _ expr _ _)) -- The two-step process avoids getting two errors: one from -- the expression itself, and one from the 'print it' part -- This two-step story is very clunky, alas - , do { _ <- checkNoErrs (tcGhciStmts [let_stmt]) + , do { _ <- checkNoErrs (discardWarnings (tcGhciStmts [let_stmt])) --- checkNoErrs defeats the error recovery of let-bindings + --- discardWarnings: warnings come from the second typecheck ; tcGhciStmts [let_stmt, print_it] } ] -- Plans where we don't bind "it" ===================================== testsuite/tests/ghci/scripts/T26233.script ===================================== @@ -0,0 +1,2 @@ +:set -Wall +truncate pi ===================================== testsuite/tests/ghci/scripts/T26233.stderr ===================================== @@ -0,0 +1,14 @@ +<interactive>:2:1: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Double’ in the following constraints + (RealFrac a0) + arising from a use of ‘truncate’ at <interactive>:2:1-8 + (Floating a0) arising from a use of ‘pi’ at <interactive>:2:10-11 + • In the expression: truncate pi + In an equation for ‘it’: it = truncate pi + +<interactive>:2:1: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraints + (Show a0) arising from a use of ‘print’ at <interactive>:2:1-11 + (Integral a0) arising from a use of ‘it’ at <interactive>:2:1-11 + • In a stmt of an interactive GHCi command: print it + ===================================== testsuite/tests/ghci/scripts/T26233.stdout ===================================== @@ -0,0 +1 @@ +3 ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -391,3 +391,4 @@ test('GhciPackageRename', [extra_hc_opts("-hide-all-packages -package 'containers (Data.Map as Prelude)'")], ghci_script, ['GhciPackageRename.script']) +test('T26233', normal, ghci_script, ['T26233.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/585d7450248a71ef27bc2b67a8463275... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/585d7450248a71ef27bc2b67a8463275... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)