summaryrefslogtreecommitdiff
path: root/testsuite/tests/parser/should_fail/T984.stderr
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2019-04-23 21:21:33 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2019-05-03 21:54:50 +0300
commit52fc2719b93ab39be3e52eba531ee173b9134183 (patch)
tree2ee2a341d5cc747707765ecf8695795a4ca0eb4b /testsuite/tests/parser/should_fail/T984.stderr
parent8f929388c4b79b82a6e7772720d785f3cbc1f3c1 (diff)
downloadhaskell-52fc2719b93ab39be3e52eba531ee173b9134183.tar.gz
Pattern/expression ambiguity resolution
This patch removes 'EWildPat', 'EAsPat', 'EViewPat', and 'ELazyPat' from 'HsExpr' by using the ambiguity resolution system introduced earlier for the command/expression ambiguity. Problem: there are places in the grammar where we do not know whether we are parsing an expression or a pattern, for example: do { Con a b <- x } -- 'Con a b' is a pattern do { Con a b } -- 'Con a b' is an expression Until we encounter binding syntax (<-) we don't know whether to parse 'Con a b' as an expression or a pattern. The old solution was to parse as HsExpr always, and rejig later: checkPattern :: LHsExpr GhcPs -> P (LPat GhcPs) This meant polluting 'HsExpr' with pattern-related constructors. In other words, limitations of the parser were affecting the AST, and all other code (the renamer, the typechecker) had to deal with these extra constructors. We fix this abstraction leak by parsing into an overloaded representation: class DisambECP b where ... newtype ECP = ECP { runECP_PV :: forall b. DisambECP b => PV (Located b) } See Note [Ambiguous syntactic categories] for details. Now the intricacies of parsing have no effect on the hsSyn AST when it comes to the expression/pattern ambiguity.
Diffstat (limited to 'testsuite/tests/parser/should_fail/T984.stderr')
-rw-r--r--testsuite/tests/parser/should_fail/T984.stderr4
1 files changed, 2 insertions, 2 deletions
diff --git a/testsuite/tests/parser/should_fail/T984.stderr b/testsuite/tests/parser/should_fail/T984.stderr
index 4c723a7869..6d25a36e9e 100644
--- a/testsuite/tests/parser/should_fail/T984.stderr
+++ b/testsuite/tests/parser/should_fail/T984.stderr
@@ -1,4 +1,4 @@
-T984.hs:6:9:
- Parse error in pattern: case () of { _ -> result }
+T984.hs:6:9: error:
+ (case ... of ...)-syntax in pattern
Possibly caused by a missing 'do'?