Skip to content

Commit

Permalink
[ error ] Improve error messages for indentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhamsteve authored and gallais committed May 13, 2023
1 parent c285ef0 commit 7221c99
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Idris/Parser.idr
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,8 @@ mutual
rhs <- typeExpr pdef fname indents
ws <- option [] $ whereBlock fname col
pure (rhs, ws)
atEnd indents
b' <- bounds peek
mustWorkBecause b'.bounds "Not the end of a block entry, check indentation" $ atEnd indents
(rhs, ws) <- pure b.val
let fc = boundToFC fname (mergeBounds start b)
pure (MkPatClause fc (uncurry applyArgs lhs) rhs ws)
Expand Down
2 changes: 1 addition & 1 deletion tests/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
"perror026", "perror027"]

idrisTestsInteractive : TestPool
idrisTestsInteractive = MkTestPool "Interactive editing" [] Nothing
Expand Down
5 changes: 5 additions & 0 deletions tests/idris2/perror027/Outdent.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
countdown : (secs: Nat) -> IO ()
countdown Z = putStrLn "Lift off!"
countdown (S secs) = do putStrLn (show (S secs))
usleep 1000000
countdown secs
10 changes: 10 additions & 0 deletions tests/idris2/perror027/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1/1: Building Outdent (Outdent.idr)
Error: Not the end of a block entry, check indentation.

Outdent:4:22--4:28
1 | countdown : (secs: Nat) -> IO ()
2 | countdown Z = putStrLn "Lift off!"
3 | countdown (S secs) = do putStrLn (show (S secs))
4 | usleep 1000000
^^^^^^

3 changes: 3 additions & 0 deletions tests/idris2/perror027/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rm -rf build

$1 --no-color --console-width 0 --check Outdent.idr

0 comments on commit 7221c99

Please sign in to comment.