When running the following program in the JavaScript backend, it runs forever producing < on the console, until it stack-overflows:
effect stacktrace(): Unit
def withStacktrace{ body: => Unit / stacktrace }: Unit / { stacktrace } = {
def st() = do stacktrace()
try body()
with stacktrace { () => println("<"); st(); resume(()) }
}
def allowStacktrace{ body: => Unit / stacktrace }: Unit = {
try body()
with stacktrace { () => resume(()) }
}
def foo(n: Int): Unit / stacktrace = withStacktrace {
if (n > 0) {
foo( n - 1 )
} else { do stacktrace() }
}
def main() = allowStacktrace {
foo(2)
}
(no playground link, since the playground just hangs...)
This is not the case in LLVM, Chez (also CPS), and also should not be the case.
When running the following program in the JavaScript backend, it runs forever producing
<on the console, until it stack-overflows:(no playground link, since the playground just hangs...)
This is not the case in LLVM, Chez (also CPS), and also should not be the case.