diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-06-19 21:44:17 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-06-24 20:35:56 -0400 |
commit | 4d5967b5148d5502d7c53a5a321919779c3165e4 (patch) | |
tree | 7348b3ae363486350fc0be24f9138be5362be9d3 /compiler/GHC/HsToCore | |
parent | 138b7a5775251c330ade870a0b8d1f5c4659e669 (diff) | |
download | haskell-4d5967b5148d5502d7c53a5a321919779c3165e4.tar.gz |
Fixes around incomplete guards (#20023, #20024)
- Fix linearity error with incomplete MultiWayIf (#20023)
- Fix partial pattern binding error message (#20024)
- Remove obsolete test LinearPolyTest
It tested the special typing rule for ($), which was removed
during the implementation of Quick Look 97cff9190d3.
- Fix ticket numbers in linear/*/all.T, they referred to linear types
issue tracker
Diffstat (limited to 'compiler/GHC/HsToCore')
-rw-r--r-- | compiler/GHC/HsToCore/GuardedRHSs.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Utils.hs | 15 |
2 files changed, 8 insertions, 10 deletions
diff --git a/compiler/GHC/HsToCore/GuardedRHSs.hs b/compiler/GHC/HsToCore/GuardedRHSs.hs index 6f1de8ae16..8ecf6c84ed 100644 --- a/compiler/GHC/HsToCore/GuardedRHSs.hs +++ b/compiler/GHC/HsToCore/GuardedRHSs.hs @@ -49,7 +49,8 @@ necessary. The type argument gives the type of the @ei@. dsGuarded :: GRHSs GhcTc (LHsExpr GhcTc) -> Type -> NonEmpty Nablas -> DsM CoreExpr dsGuarded grhss rhs_ty rhss_nablas = do match_result <- dsGRHSs PatBindRhs grhss rhs_ty rhss_nablas - error_expr <- mkErrorAppDs nON_EXHAUSTIVE_GUARDS_ERROR_ID rhs_ty empty + error_expr <- mkErrorAppDs nON_EXHAUSTIVE_GUARDS_ERROR_ID rhs_ty + (text "pattern binding") extractMatchResult match_result error_expr -- In contrast, @dsGRHSs@ produces a @MatchResult CoreExpr@. diff --git a/compiler/GHC/HsToCore/Utils.hs b/compiler/GHC/HsToCore/Utils.hs index b68cf061a0..5c68525f12 100644 --- a/compiler/GHC/HsToCore/Utils.hs +++ b/compiler/GHC/HsToCore/Utils.hs @@ -405,11 +405,10 @@ mkErrorAppDs :: Id -- The error function mkErrorAppDs err_id ty msg = do src_loc <- getSrcSpanDs dflags <- getDynFlags - let - full_msg = showSDoc dflags (hcat [ppr src_loc, vbar, msg]) - core_msg = Lit (mkLitString full_msg) - -- mkLitString returns a result of type String# - return (mkApps (Var err_id) [Type (getRuntimeRep ty), Type ty, core_msg]) + let full_msg = showSDoc dflags (hcat [ppr src_loc, vbar, msg]) + fail_expr = mkRuntimeErrorApp err_id unitTy full_msg + return $ mkWildCase fail_expr (unrestricted unitTy) ty [] + -- See Note [Incompleteness and linearity] {- Note [Incompleteness and linearity] @@ -426,7 +425,7 @@ the linearity of x. Instead, we use 'f x False = case error "Non-exhausive pattern..." :: () of {}'. This case expression accounts for linear variables by assigning bottom usage (See Note [Bottom as a usage] in GHC.Core.Multiplicity). -This is done in mkFailExpr. +This is done in mkErrorAppDs, called from mkFailExpr. We use '()' instead of the original return type ('a' in this case) because there might be representation polymorphism, e.g. in @@ -458,9 +457,7 @@ is disabled. mkFailExpr :: HsMatchContext GhcRn -> Type -> DsM CoreExpr mkFailExpr ctxt ty - = do fail_expr <- mkErrorAppDs pAT_ERROR_ID unitTy (matchContextErrString ctxt) - return $ mkWildCase fail_expr (unrestricted unitTy) ty [] - -- See Note [Incompleteness and linearity] + = mkErrorAppDs pAT_ERROR_ID ty (matchContextErrString ctxt) {- 'mkCoreAppDs' and 'mkCoreAppsDs' handle the special-case desugaring of 'seq'. |