Commit 4d41e921 authored by Ryan Scott's avatar Ryan Scott

Improve treatment of sectioned holes

Summary:
Previously, GHC was pretty-printing left-section holes
incorrectly and not parsing right-sectioned holes at all. This patch
fixes both problems.

Test Plan: make test TEST=T14590

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #14590

Differential Revision: https://phabricator.haskell.org/D4273
parent b6304f8f
......@@ -883,6 +883,8 @@ ppr_expr (SectionL expr op)
= case unLoc op of
HsVar (L _ v) -> pp_infixly v
HsConLikeOut c -> pp_infixly (conLikeName c)
HsUnboundVar h@TrueExprHole{}
-> pp_infixly (unboundVarOcc h)
_ -> pp_prefixly
where
pp_expr = pprDebugParendExpr expr
......@@ -895,6 +897,8 @@ ppr_expr (SectionR op expr)
= case unLoc op of
HsVar (L _ v) -> pp_infixly v
HsConLikeOut c -> pp_infixly (conLikeName c)
HsUnboundVar h@TrueExprHole{}
-> pp_infixly (unboundVarOcc h)
_ -> pp_prefixly
where
pp_expr = pprDebugParendExpr expr
......
......@@ -3178,13 +3178,17 @@ varop :: { Located RdrName }
qop :: { LHsExpr GhcPs } -- 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] }
| hole_op { $1 }
qopm :: { LHsExpr GhcPs } -- used in sections
: qvaropm { sL1 $1 $ HsVar $1 }
| qconop { sL1 $1 $ HsVar $1 }
| hole_op { $1 }
hole_op :: { LHsExpr GhcPs } -- used in sections
hole_op : '`' '_' '`' {% ams (sLL $1 $> EWildPat)
[mj AnnBackquote $1,mj AnnVal $2
,mj AnnBackquote $3] }
qvarop :: { Located RdrName }
: qvarsym { $1 }
......
module T14590 where
f1, f2, f3, f4 :: Int -> Int -> Int
f1 x y = (x `_`) y
f2 x y = (x `_a`) y
f3 x y = (`_` x) y
f4 x y = (`_a` x) y
This diff is collapsed.
......@@ -586,3 +586,4 @@ test('T14434', [], run_command, ['$MAKE -s --no-print-directory T14434'])
test('MissingExportList01', normal, compile, [''])
test('MissingExportList02', normal, compile, [''])
test('T14488', normal, compile, [''])
test('T14590', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment