links
links copied to clipboard
CPS compilation is broken for inlined handled computations
The following program does not produce any output
fun run() {
handle({
println(intToString(do Foo(40,2)))
}) {
case <Foo(x,y) => resume> -> resume(x+y)
}
}
fun mainPage(_) {
page
<#><button l:onclick="{run()}">Click me!</button></#>
}
fun main() {
addRoute("/", mainPage);
servePages()
}
main()
after hoisting the inlined computation to a thunk, the program produces the expected output
fun f() {
println(intToString(do Foo(40,2)))
}
fun run() {
handle(f()) {
case <Foo(x,y) => resume> -> resume(x+y)
}
}
fun mainPage(_) {
page
<#><button l:onclick="{run()}">Click me!</button></#>
}
fun main() {
addRoute("/", mainPage);
servePages()
}
main()
The problem seems to be that the inlined computation is being compiled with the wrong continuation.