diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-08-12 18:35:28 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-10 10:35:33 -0400 |
commit | 67ce72da1689058cb689ffbb6fcbd5cd12af56df (patch) | |
tree | 694ee73ed29fc5953b1cc2f57c72f0761c8ad5dc /compiler/GHC/HsToCore/GuardedRHSs.hs | |
parent | 4798caa0fefd7adf4c5b85fa84a6f28fcc6b350b (diff) | |
download | haskell-67ce72da1689058cb689ffbb6fcbd5cd12af56df.tar.gz |
Add long-distance info for pattern bindings (#18572)
We didn't consider the RHS of a pattern-binding before, which led to
surprising warnings listed in #18572.
As can be seen from the regression test T18572, we get the expected
output now.
Diffstat (limited to 'compiler/GHC/HsToCore/GuardedRHSs.hs')
-rw-r--r-- | compiler/GHC/HsToCore/GuardedRHSs.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/GHC/HsToCore/GuardedRHSs.hs b/compiler/GHC/HsToCore/GuardedRHSs.hs index 6ff171febc..55ede1ddcb 100644 --- a/compiler/GHC/HsToCore/GuardedRHSs.hs +++ b/compiler/GHC/HsToCore/GuardedRHSs.hs @@ -36,7 +36,7 @@ import Control.Monad ( zipWithM ) import Data.List.NonEmpty ( NonEmpty, toList ) {- -@dsGuarded@ is used for pattern bindings. +@dsGuarded@ is used for GRHSs. It desugars: \begin{verbatim} | g1 -> e1 @@ -44,7 +44,7 @@ It desugars: | gn -> en where binds \end{verbatim} -producing an expression with a runtime error in the corner if +producing an expression with a runtime error in the corner case if necessary. The type argument gives the type of the @ei@. -} @@ -137,8 +137,8 @@ matchGuards (BindStmt _ pat bind_rhs : stmts) ctx deltas rhs rhs_ty = do match_result <- matchGuards stmts ctx deltas rhs rhs_ty core_rhs <- dsLExpr bind_rhs - match_result' <- matchSinglePatVar match_var (StmtCtxt ctx) pat rhs_ty - match_result + match_result' <- matchSinglePatVar match_var (Just core_rhs) (StmtCtxt ctx) + pat rhs_ty match_result pure $ bindNonRec match_var core_rhs <$> match_result' matchGuards (LastStmt {} : _) _ _ _ _ = panic "matchGuards LastStmt" |