From 357f273838e874d29717c90ab2cf3ea802550e97 Mon Sep 17 00:00:00 2001 From: Sebastian Graf <sebastian.graf@kit.edu> Date: Fri, 5 May 2023 09:44:30 +0200 Subject: [PATCH] Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345) --- libraries/ghc-bignum/ghc-bignum.cabal | 12 ++++++++---- libraries/ghc-bignum/src/GHC/Num/BigNat.hs | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/libraries/ghc-bignum/ghc-bignum.cabal b/libraries/ghc-bignum/ghc-bignum.cabal index 45bb2b904dea..994a4a6aeabe 100644 --- a/libraries/ghc-bignum/ghc-bignum.cabal +++ b/libraries/ghc-bignum/ghc-bignum.cabal @@ -84,10 +84,14 @@ library ghc-options: -Wall cc-options: -std=c99 -Wall - -- GHC has wired-in IDs from the ghc-bignum package. Hence the unit-id - -- of the package should not contain the version: i.e. it must be - -- "ghc-bignum" and not "ghc-bignum-1.0". - ghc-options: -this-unit-id ghc-bignum + ghc-options: + -- GHC has wired-in IDs from the ghc-bignum package. Hence the unit-id + -- of the package should not contain the version: i.e. it must be + -- "ghc-bignum" and not "ghc-bignum-1.0". + -this-unit-id ghc-bignum + + -- See Note [ghc-bignum and error symbols] + -fno-catch-nonexhaustive-cases if flag(gmp) cpp-options: -DBIGNUM_GMP diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs index efe78f10c901..21b07cb8300f 100644 --- a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs +++ b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs @@ -1645,3 +1645,22 @@ instance Ord BigNat where BN# a > BN# b = bigNatGt a b BN# a >= BN# b = bigNatGe a b +{- Note [ghc-bignum and error symbols] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ghc-bignum only depends on ghc-prim, not base. +Hence it may not introduce any symbol references to the error symbols in +Control.Exception.Base such as `patError` or `impossibleError`, otherwise +we get linker errors. + +This implies that + + * Every pattern match must be "obviously complete", otherwise GHC's desugaring + inserts `patError`s for the missing cases. "Obviously complete" in the sense + that the desugarer is able to infer completeness, so considering type info + but not long distance information (as the pattern-match checker would do). + * We compile with -fno-catch-nonexhaustive-cases so that we don't risk + introducing `impossibleError` + * ... probably other similar observations that will be added to this list in + the future ... + +-} -- GitLab