Skip to content

Commit 0a1de1e

Browse files
committed
fix(switch): add missing begin around switch impl so that it can used as an expression
1 parent 4e04827 commit 0a1de1e

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Switch.ark

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
# @author https://github.com/SuperFola
2323
(macro switch (value case then ...cases) {
2424
(macro var ($gensym))
25-
(let var value)
26-
(_switch_impl var case then ...cases) })
25+
{
26+
(let var value)
27+
(_switch_impl var case then ...cases) } })

tests/switch-tests.ark

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@
3636
(switch (let n 1)
3737
0 (test:expect false)
3838
1 (test:expect true)
39-
_ (test:expect false)) })
39+
_ (test:expect false))
40+
41+
# (switch ...) should count as a single expression
42+
(test:eq (+ 0 (switch 1 1 1)) 1)
43+
(test:eq ((fun () (switch 1 1 1))) 1) })

0 commit comments

Comments
 (0)