Skip to content

Commit 1276f47

Browse files
committed
Fix #1767
The `if then else` syntax expects a block for the `then` and `else` parts. Before this patch, the token `InterpEnd` was not a valid follow up token to end a block. This adds `InterpEnd` as a closing token for blocks, allowing `if then else` in interpolation slices without additional parens.
1 parent 9f0a706 commit 1276f47

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

src/Parser/Rule/Source.idr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ isTerminator (Keyword "in") = True
400400
isTerminator (Keyword "then") = True
401401
isTerminator (Keyword "else") = True
402402
isTerminator (Keyword "where") = True
403+
isTerminator InterpEnd = True
403404
isTerminator EndInput = True
404405
isTerminator _ = False
405406

tests/Main.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ idrisTestsBasic = MkTestPool "Fundamental language features" [] Nothing
4141
"basic046", "basic047", "basic049", "basic050",
4242
"basic051", "basic052", "basic053", "basic054", "basic055",
4343
"basic056", "basic057", "basic058", "basic059", "basic060",
44-
"basic061"]
44+
"basic061", "interpolation001"]
4545

4646
idrisTestsCoverage : TestPool
4747
idrisTestsCoverage = MkTestPool "Coverage checking" [] Nothing
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ifthenelse : String
2+
ifthenelse = "\{ if True then "a" else "b" }"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1/1: Building IfThenElse (IfThenElse.idr)

tests/idris2/interpolation001/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rm -rf build
2+
3+
$1 --no-color --console-width 0 --no-banner --check --alt-error-count 10 IfThenElse.idr
4+

0 commit comments

Comments
 (0)