mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 12:42:02 +03:00
Merge pull request #2926 from Alex1005a/let-in-do
Add explicit error when using let-in in do block
This commit is contained in:
commit
1fa59f842a
@ -922,7 +922,10 @@ mutual
|
||||
<|> do decoratedKeyword fname "let"
|
||||
commit
|
||||
res <- nonEmptyBlock (letBlock fname)
|
||||
atEnd indents
|
||||
do b <- bounds (decoratedKeyword fname "in")
|
||||
fatalLoc {c = True} b.bounds "Let-in not supported in do block. Did you mean (let ... in ...)?"
|
||||
<|>
|
||||
do atEnd indents
|
||||
pure (mkDoLets fname res)
|
||||
<|> do b <- bounds (decoratedKeyword fname "rewrite" *> expr pdef fname indents)
|
||||
atEnd indents
|
||||
|
@ -96,7 +96,7 @@ idrisTestsError = MkTestPool "Error messages" [] Nothing
|
||||
"perror011", "perror012", "perror013", "perror014", "perror015",
|
||||
"perror016", "perror017", "perror018", "perror019", "perror020",
|
||||
"perror021", "perror022", "perror023", "perror024", "perror025",
|
||||
"perror026", "perror027"]
|
||||
"perror026", "perror027", "perror028"]
|
||||
|
||||
idrisTestsInteractive : TestPool
|
||||
idrisTestsInteractive = MkTestPool "Interactive editing" [] Nothing
|
||||
|
6
tests/idris2/perror028/LetInDo.idr
Normal file
6
tests/idris2/perror028/LetInDo.idr
Normal file
@ -0,0 +1,6 @@
|
||||
module LetInDo
|
||||
|
||||
letInDo : Monad m => m Int
|
||||
letInDo = do
|
||||
y <- pure 10
|
||||
let x = 5 in pure $ y + x
|
11
tests/idris2/perror028/expected
Normal file
11
tests/idris2/perror028/expected
Normal file
@ -0,0 +1,11 @@
|
||||
1/1: Building LetInDo (LetInDo.idr)
|
||||
Error: Let-in not supported in do block. Did you mean (let ... in ...)?.
|
||||
|
||||
LetInDo:6:13--6:15
|
||||
2 |
|
||||
3 | letInDo : Monad m => m Int
|
||||
4 | letInDo = do
|
||||
5 | y <- pure 10
|
||||
6 | let x = 5 in pure $ y + x
|
||||
^^
|
||||
|
3
tests/idris2/perror028/run
Normal file
3
tests/idris2/perror028/run
Normal file
@ -0,0 +1,3 @@
|
||||
rm -rf build
|
||||
|
||||
$1 --no-color --console-width 0 --check LetInDo.idr
|
Loading…
Reference in New Issue
Block a user