[commit: ghc] ghc-8.0: RnExpr: Actually fail if patterns found in expression (47ae01b)
git at git.haskell.org
git at git.haskell.org
Thu Oct 13 15:16:13 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/47ae01bfb7ca426188d85c6ecb33ebbacc837aa6/ghc
>---------------------------------------------------------------
commit 47ae01bfb7ca426188d85c6ecb33ebbacc837aa6
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Tue Oct 11 09:26:46 2016 -0400
RnExpr: Actually fail if patterns found in expression
This fixes #12584, where wildcard patterns were snuck into an
expression, which then crashed the typechecker in TcExpr since EWildPats
aren't supposed to appear in the AST after renaming.
The problem was that `rnTopSpliceDecl` failed to check for errors from
`rnSplice` (as done by other callers to `rnSplice`).
Thanks to Shayan for reporting this!
Reviewers: simonpj, austin
Reviewed By: simonpj
Subscribers: simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D2539
GHC Trac Issues: #12584
(cherry picked from commit bce99086e9f54909f51ff5a74cb8c666083bb021)
>---------------------------------------------------------------
47ae01bfb7ca426188d85c6ecb33ebbacc837aa6
compiler/rename/RnSplice.hs | 5 ++++-
testsuite/tests/rename/should_fail/all.T | 1 +
testsuite/tests/rename/should_fail/rnfail016.hs | 2 --
testsuite/tests/rename/should_fail/rnfail016.stderr | 2 --
testsuite/tests/rename/should_fail/{rnfail016.hs => rnfail016a.hs} | 5 +----
testsuite/tests/rename/should_fail/rnfail016a.stderr | 2 ++
6 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/compiler/rename/RnSplice.hs b/compiler/rename/RnSplice.hs
index 0dc4487..c66886f 100644
--- a/compiler/rename/RnSplice.hs
+++ b/compiler/rename/RnSplice.hs
@@ -593,8 +593,11 @@ rnSpliceDecl (SpliceDecl (L loc splice) flg)
rnTopSpliceDecls :: HsSplice RdrName -> RnM ([LHsDecl RdrName], FreeVars)
-- Declaration splice at the very top level of the module
rnTopSpliceDecls splice
- = do { (rn_splice, fvs) <- setStage (Splice Untyped) $
+ = do { (rn_splice, fvs) <- checkNoErrs $
+ setStage (Splice Untyped) $
rnSplice splice
+ -- As always, be sure to checkNoErrs above lest we end up with
+ -- holes making it to typechecking, hence #12584.
; traceRn (text "rnTopSpliceDecls: untyped declaration splice")
; (decls, mod_finalizers) <-
runRnSplice UntypedDeclSplice runMetaD ppr_decls rn_splice
diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T
index e9ea297..fc04e5c 100644
--- a/testsuite/tests/rename/should_fail/all.T
+++ b/testsuite/tests/rename/should_fail/all.T
@@ -13,6 +13,7 @@ test('rnfail013', normal, compile_fail, [''])
test('rnfail015', normal, compile_fail, [''])
test('rnfail016', normal, compile_fail, [''])
+test('rnfail016a', normal, compile_fail, [''])
test('rnfail017', normal, compile_fail, [''])
test('rnfail018', normal, compile_fail, [''])
test('rnfail019', normal, compile_fail, [''])
diff --git a/testsuite/tests/rename/should_fail/rnfail016.hs b/testsuite/tests/rename/should_fail/rnfail016.hs
index 1bf15b0..7dccaa9 100644
--- a/testsuite/tests/rename/should_fail/rnfail016.hs
+++ b/testsuite/tests/rename/should_fail/rnfail016.hs
@@ -4,6 +4,4 @@ module ShouldFail where
-- !!! Pattern syntax in expressions
f x = x @ x
-g x = ~ x
-h x = _
diff --git a/testsuite/tests/rename/should_fail/rnfail016.stderr b/testsuite/tests/rename/should_fail/rnfail016.stderr
index 4013255..4743613 100644
--- a/testsuite/tests/rename/should_fail/rnfail016.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail016.stderr
@@ -2,5 +2,3 @@
rnfail016.hs:6:7: error:
Pattern syntax in expression context: x at x
Did you mean to enable TypeApplications?
-
-rnfail016.hs:7:7: error: Pattern syntax in expression context: ~x
diff --git a/testsuite/tests/rename/should_fail/rnfail016.hs b/testsuite/tests/rename/should_fail/rnfail016a.hs
similarity index 77%
copy from testsuite/tests/rename/should_fail/rnfail016.hs
copy to testsuite/tests/rename/should_fail/rnfail016a.hs
index 1bf15b0..e0d7d65 100644
--- a/testsuite/tests/rename/should_fail/rnfail016.hs
+++ b/testsuite/tests/rename/should_fail/rnfail016a.hs
@@ -3,7 +3,4 @@ module ShouldFail where
-- !!! Pattern syntax in expressions
-f x = x @ x
-g x = ~ x
-h x = _
-
+f x = ~ x
diff --git a/testsuite/tests/rename/should_fail/rnfail016a.stderr b/testsuite/tests/rename/should_fail/rnfail016a.stderr
new file mode 100644
index 0000000..3a59ee7
--- /dev/null
+++ b/testsuite/tests/rename/should_fail/rnfail016a.stderr
@@ -0,0 +1,2 @@
+
+rnfail016a.hs:6:7: error: Pattern syntax in expression context: ~x
More information about the ghc-commits
mailing list