Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
-
d3209b4e
by Javran Cheng at 2025-05-01T09:33:33-04:00
4 changed files:
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/Tc/Utils/TcType.hs
- testsuite/tests/printer/T17697.stderr
Changes:
| ... | ... | @@ -510,6 +510,17 @@ Wrinkles: |
| 510 | 510 | |
| 511 | 511 | See examples in ghc-prim:GHC.Types
|
| 512 | 512 | |
| 513 | +(Any8) Warning about unused bindings of type `Any` and `ZonkAny` are suppressed,
|
|
| 514 | + following the same rationale of supressing warning about the unit type.
|
|
| 515 | + |
|
| 516 | + For example, consider (#25895):
|
|
| 517 | + |
|
| 518 | + do { forever (return ()); blah }
|
|
| 519 | + |
|
| 520 | + where forever :: forall a b. IO a -> IO b
|
|
| 521 | + Nothing constrains `b`, so it will be instantiates with `Any` or `ZonkAny`.
|
|
| 522 | + But we certainly don't want to complain about a discarded do-binding.
|
|
| 523 | + |
|
| 513 | 524 | The Any tycon used to be quite magic, but we have since been able to
|
| 514 | 525 | implement it merely with an empty kind polymorphic type family. See #10886 for a
|
| 515 | 526 | bit of history.
|
| ... | ... | @@ -1243,9 +1243,13 @@ warnDiscardedDoBindings rhs m_ty elt_ty |
| 1243 | 1243 | ; when (warn_unused || warn_wrong) $
|
| 1244 | 1244 | do { fam_inst_envs <- dsGetFamInstEnvs
|
| 1245 | 1245 | ; let norm_elt_ty = topNormaliseType fam_inst_envs elt_ty
|
| 1246 | - |
|
| 1247 | - -- Warn about discarding non-() things in 'monadic' binding
|
|
| 1248 | - ; if warn_unused && not (isUnitTy norm_elt_ty)
|
|
| 1246 | + supressible_ty =
|
|
| 1247 | + isUnitTy norm_elt_ty || isAnyTy norm_elt_ty || isZonkAnyTy norm_elt_ty
|
|
| 1248 | + -- Warn about discarding things in 'monadic' binding,
|
|
| 1249 | + -- however few types are excluded:
|
|
| 1250 | + -- * Unit type `()`
|
|
| 1251 | + -- * `ZonkAny` or `Any` type see (Any8) of Note [Any types]
|
|
| 1252 | + ; if warn_unused && not supressible_ty
|
|
| 1249 | 1253 | then diagnosticDs (DsUnusedDoBind rhs elt_ty)
|
| 1250 | 1254 | else
|
| 1251 | 1255 |
| ... | ... | @@ -88,7 +88,7 @@ module GHC.Tc.Utils.TcType ( |
| 88 | 88 | isSigmaTy, isRhoTy, isRhoExpTy, isOverloadedTy,
|
| 89 | 89 | isFloatingPrimTy, isDoubleTy, isFloatTy, isIntTy, isWordTy, isStringTy,
|
| 90 | 90 | isIntegerTy, isNaturalTy,
|
| 91 | - isBoolTy, isUnitTy, isCharTy,
|
|
| 91 | + isBoolTy, isUnitTy, isAnyTy, isZonkAnyTy, isCharTy,
|
|
| 92 | 92 | isTauTy, isTauTyCon, tcIsTyVarTy,
|
| 93 | 93 | isPredTy, isTyVarClassPred,
|
| 94 | 94 | checkValidClsArgs, hasTyVarHead,
|
| ... | ... | @@ -2006,7 +2006,7 @@ isFloatTy, isDoubleTy, |
| 2006 | 2006 | isFloatPrimTy, isDoublePrimTy,
|
| 2007 | 2007 | isIntegerTy, isNaturalTy,
|
| 2008 | 2008 | isIntTy, isWordTy, isBoolTy,
|
| 2009 | - isUnitTy, isCharTy :: Type -> Bool
|
|
| 2009 | + isUnitTy, isAnyTy, isZonkAnyTy, isCharTy :: Type -> Bool
|
|
| 2010 | 2010 | isFloatTy = is_tc floatTyConKey
|
| 2011 | 2011 | isDoubleTy = is_tc doubleTyConKey
|
| 2012 | 2012 | isFloatPrimTy = is_tc floatPrimTyConKey
|
| ... | ... | @@ -2017,6 +2017,8 @@ isIntTy = is_tc intTyConKey |
| 2017 | 2017 | isWordTy = is_tc wordTyConKey
|
| 2018 | 2018 | isBoolTy = is_tc boolTyConKey
|
| 2019 | 2019 | isUnitTy = is_tc unitTyConKey
|
| 2020 | +isAnyTy = is_tc anyTyConKey
|
|
| 2021 | +isZonkAnyTy = is_tc zonkAnyTyConKey
|
|
| 2020 | 2022 | isCharTy = is_tc charTyConKey
|
| 2021 | 2023 | |
| 2022 | 2024 | -- | Check whether the type is of the form @Any :: k@,
|
| 1 | 1 | T17697.hs:6:5: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables (in -Wdefault)]
|
| 2 | 2 | Variable not in scope: threadDelay :: t0 -> IO a0 |
| 3 | - |
|
| 4 | -T17697.hs:6:5: warning: [GHC-81995] [-Wunused-do-bind (in -Wall)]
|
|
| 5 | - A do-notation statement discarded a result of type
|
|
| 6 | - ‘GHC.Internal.Types.ZonkAny 1’
|
|
| 7 | - Suggested fix: Suppress this warning by saying ‘_ <- threadDelay 1’
|
|
| 8 | - |