Skip to content

Commit a4864e9

Browse files
committed
Document another case of GHC-53786
A case-expression inside a do-block whose branch expression is missing a `do` parses unintuitively, resulting in a confusing GHC-53786. It seems worthwhile to document this explicitly.
1 parent 48e7e15 commit a4864e9

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module CaseExprInDoBlock where
2+
3+
x :: [a]
4+
x = do
5+
case () of
6+
() -> do
7+
a <- []
8+
pure a
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module CaseExprInDoBlock where
2+
3+
x :: [a]
4+
x = do
5+
case () of
6+
() ->
7+
a <- []
8+
pure a
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Case expression in do-block
3+
---
4+
5+
The expression in one branch of the case expression is a do-block that's missing a `do`; the whole case-expression is interpreted as LHS of a bind in the top-level do-block. See also: https://gitlab.haskell.org/ghc/ghc/-/issues/984
6+
7+
## Error Message
8+
9+
```
10+
CaseExprInDoBlock.hs:5:3: error: [GHC-53786]
11+
(case ... of ...)-syntax in pattern
12+
|
13+
5 | case () of
14+
| ^^^^^^^^^^...
15+
16+
```

0 commit comments

Comments
 (0)