diff --git a/test/cgen/returnscrut.kk b/test/cgen/returnscrut.kk new file mode 100644 index 000000000..39cd91c74 --- /dev/null +++ b/test/cgen/returnscrut.kk @@ -0,0 +1,29 @@ +// Issue: https://github.com/koka-lang/koka/issues/644 +fun main() + println("Compiled") + +type token + Int + +value struct token-iter + chars: vector + idx: ref + +fun token-iter/next(token-iter: token-iter): , write> 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 diff --git a/test/cgen/returnscrut.kk.out b/test/cgen/returnscrut.kk.out new file mode 100644 index 000000000..7405d4c10 --- /dev/null +++ b/test/cgen/returnscrut.kk.out @@ -0,0 +1 @@ +Compiled \ No newline at end of file