Skip to content

Commit

Permalink
adding a FIXME to this; tracked in #18
Browse files Browse the repository at this point in the history
  • Loading branch information
kavon committed Mar 25, 2020
1 parent 426a2eb commit 9ad955a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/regression-tests/goals/seq-cont/alt-ret-tuple.pml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@ fun snd (_, x) = x
fun max (a, b) = if a > b then a else b

(* fib that alternates between returning normally or using its escape cont *)
fun fib n k = (case n
of 0 => altRet (n, (0, 1), k)
| 1 => altRet (n, (1, 1), k)
| _ => let
(* FIXME: if you change the `if` below into

case n
of 0 => altRet (n, (0, 1), k)
| 1 => altRet (n, (1, 1), k)
| _ => let ...

Then you get the wrong answer, but only when using hybridstacks.
It's not in the ASM code, since the generated ASM is identical to
that of segmented stacks. So there must be something wrong in the RTS.
*)
fun fib n k =
if n <= 1
then altRet (n, (n, 1), k)
else let
val left = Cont.callec (fib (n-1))
val right = Cont.callec (fib (n-2))
val ans = fst left + fst right
val depth = max (snd left, snd right) + 1
in
altRet (n, (ans, depth), k)
end
(* end case *))

val i2s = Int.toString

Expand Down

0 comments on commit 9ad955a

Please sign in to comment.