Skip to content

Commit

Permalink
Add issue test
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWhiting committed Dec 22, 2024
1 parent 3b07c76 commit b6ecca0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/cgen/reused-names.kk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Issue: https://github.com/koka-lang/koka/issues/186
alias elem = int

fun sequences(xs : list<elem>)
match xs
Cons(a, Cons(b, xs)) ->
if(a > b) then descending(b, [a], xs)
else ascending(b, (fn(x) { Cons(a, x) }), xs)
_ -> [xs]

fun descending(a : elem, as_, bs)
match bs
Cons(b, bs) | a > b -> descending(b, Cons(a, as_), bs)
_ -> Cons(Cons(a, as_), sequences(bs))

fun ascending(a : elem, as_, bs)
match bs
Cons(b, bs) | !(a > b) -> ascending(b, fn(ys) { as_(Cons(a, ys)) }, bs)
_ -> Cons(as_([a]), sequences(bs))

fun main()
sequences([0, 1, 2, 3])
1 change: 1 addition & 0 deletions test/cgen/reused-names.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[0,1,2,3],[]]

0 comments on commit b6ecca0

Please sign in to comment.