Skip to content

Commit

Permalink
test file for #644 (fixed with previous commit?)
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Jan 29, 2025
1 parent 1e962be commit d50350c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/cgen/returnscrut.kk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Issue: https://github.com/koka-lang/koka/issues/644
fun main()
println("Compiled")

type token
Int

value struct token-iter<h>
chars: vector<char>
idx: ref<h, int>

fun token-iter/next(token-iter: token-iter<h>): <div, read<h>, write<h>> maybe<(int, token)>
// Strange code below to work around issues with early returns in Koka 3.1.2.
// (https://github.com/koka-lang/koka/discussions/643)

// Skip whitespace
val next-char0 =
match Nothing
Just((_idx, _c)) ->
if True then
return token-iter.next
else
Nothing
Nothing -> Nothing
val tmp = match next-char0
Nothing -> return Nothing
Just(c) -> c
val (_char-idx, _char) = tmp
Nothing
1 change: 1 addition & 0 deletions test/cgen/returnscrut.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compiled

0 comments on commit d50350c

Please sign in to comment.