summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2017-01-08 07:52:53 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2017-01-08 07:53:06 +0300
commit6c869f906b879bc746ea1aa3e79e02f146d85093 (patch)
treeafbb8f916c28cbeced7e3c29dcf1e44a8c47096c /compiler
parent7b317effd59f56bc8450ea8efbb1ef5954f09e5d (diff)
downloadhaskell-6c869f906b879bc746ea1aa3e79e02f146d85093.tar.gz
Parse holes as infix operators
Reported as #13050. Since holes are expressions but not identifiers, holes were not allowed in infix operator position. This patch introduces a new production in infix operator parser to allow this. Reviewers: simonpj, austin, bgamari Reviewed By: simonpj Subscribers: simonpj, RyanGlScott, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2910 GHC Trac Issues: #13050
Diffstat (limited to 'compiler')
-rw-r--r--compiler/hsSyn/HsExpr.hs1
-rw-r--r--compiler/parser/Parser.y3
2 files changed, 4 insertions, 0 deletions
diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index 1b6ccdc1d8..18bf54aebc 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -823,6 +823,7 @@ ppr_expr (OpApp e1 op _ e2)
= case unLoc op of
HsVar (L _ v) -> pp_infixly v
HsRecFld f -> pp_infixly f
+ HsUnboundVar h@TrueExprHole{} -> pp_infixly (unboundVarOcc h)
_ -> pp_prefixly
where
pp_e1 = pprDebugParendExpr e1 -- In debug mode, add parens
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 3fc20a154f..dfb67550b5 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -3132,6 +3132,9 @@ varop :: { Located RdrName }
qop :: { LHsExpr RdrName } -- used in sections
: qvarop { sL1 $1 $ HsVar $1 }
| qconop { sL1 $1 $ HsVar $1 }
+ | '`' '_' '`' {% ams (sLL $1 $> EWildPat)
+ [mj AnnBackquote $1,mj AnnVal $2
+ ,mj AnnBackquote $3] }
qopm :: { LHsExpr RdrName } -- used in sections
: qvaropm { sL1 $1 $ HsVar $1 }