summaryrefslogtreecommitdiff
path: root/compiler/hsSyn/HsPat.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-07-20 19:24:00 -0400
committerBen Gamari <ben@smart-cactus.org>2017-07-20 19:24:01 -0400
commit36e8bcba08446dbc4e7532ef9db5517c13977bf9 (patch)
tree4b46040211993cd0a6f21c50a3bae6c8b9929570 /compiler/hsSyn/HsPat.hs
parentccac387bd90da8e1b6998e8480897a0bf0694310 (diff)
downloadhaskell-36e8bcba08446dbc4e7532ef9db5517c13977bf9.tar.gz
HsPat: Assume that no spliced patterns are irrefutable
This is a conservative assumption which will limit some uses of spliced patterns, but it fixes #13984. Test Plan: Validate Reviewers: RyanGlScott, AaronFriel, austin Reviewed By: RyanGlScott Subscribers: rwbarton, thomie GHC Trac Issues: #13984 Differential Revision: https://phabricator.haskell.org/D3766
Diffstat (limited to 'compiler/hsSyn/HsPat.hs')
-rw-r--r--compiler/hsSyn/HsPat.hs16
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/hsSyn/HsPat.hs b/compiler/hsSyn/HsPat.hs
index 93ad9ec383..f7d18768df 100644
--- a/compiler/hsSyn/HsPat.hs
+++ b/compiler/hsSyn/HsPat.hs
@@ -620,7 +620,7 @@ isIrrefutableHsPat pat
go1 (SigPatOut pat _) = go pat
go1 (TuplePat pats _ _) = all go pats
go1 (SumPat pat _ _ _) = go pat
- go1 (ListPat {}) = False
+ go1 (ListPat {}) = False
go1 (PArrPat {}) = False -- ?
go1 (ConPatIn {}) = False -- Conservative
@@ -632,15 +632,13 @@ isIrrefutableHsPat pat
go1 (ConPatOut{ pat_con = L _ (PatSynCon _pat) })
= False -- Conservative
- go1 (LitPat {}) = False
- go1 (NPat {}) = False
- go1 (NPlusKPat {}) = False
+ go1 (LitPat {}) = False
+ go1 (NPat {}) = False
+ go1 (NPlusKPat {}) = False
- -- Both should be gotten rid of by renamer before
- -- isIrrefutablePat is called
- go1 (SplicePat {}) = urk pat
-
- urk pat = pprPanic "isIrrefutableHsPat:" (ppr pat)
+ -- We conservatively assume that no TH splices are irrefutable
+ -- since we cannot know until the splice is evaluated.
+ go1 (SplicePat {}) = False
hsPatNeedsParens :: Pat a -> Bool
hsPatNeedsParens (NPlusKPat {}) = True