Merge pull request #2926 from Alex1005a/let-in-do

Add explicit error when using let-in in do block
This commit is contained in:
André Videla 2023-06-13 16:21:13 +01:00 committed by GitHub
commit 1fa59f842a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 3 deletions

View File

@ -922,7 +922,10 @@ mutual
<|> do decoratedKeyword fname "let" <|> do decoratedKeyword fname "let"
commit commit
res <- nonEmptyBlock (letBlock fname) 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) pure (mkDoLets fname res)
<|> do b <- bounds (decoratedKeyword fname "rewrite" *> expr pdef fname indents) <|> do b <- bounds (decoratedKeyword fname "rewrite" *> expr pdef fname indents)
atEnd indents atEnd indents

View File

@ -96,7 +96,7 @@ idrisTestsError = MkTestPool "Error messages" [] Nothing
"perror011", "perror012", "perror013", "perror014", "perror015", "perror011", "perror012", "perror013", "perror014", "perror015",
"perror016", "perror017", "perror018", "perror019", "perror020", "perror016", "perror017", "perror018", "perror019", "perror020",
"perror021", "perror022", "perror023", "perror024", "perror025", "perror021", "perror022", "perror023", "perror024", "perror025",
"perror026", "perror027"] "perror026", "perror027", "perror028"]
idrisTestsInteractive : TestPool idrisTestsInteractive : TestPool
idrisTestsInteractive = MkTestPool "Interactive editing" [] Nothing idrisTestsInteractive = MkTestPool "Interactive editing" [] Nothing

View File

@ -0,0 +1,6 @@
module LetInDo
letInDo : Monad m => m Int
letInDo = do
y <- pure 10
let x = 5 in pure $ y + x

View 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
^^

View File

@ -0,0 +1,3 @@
rm -rf build
$1 --no-color --console-width 0 --check LetInDo.idr