-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler crash on leftover do
-call in FFI after capability passing
#546
Comments
Hi @leonfuss, thanks for reporting! effekt/effekt/shared/src/main/scala/effekt/core/Transformer.scala Lines 527 to 528 in 68d4037
I'll rename the title to make the exact nature of the issue more apparent. The current state on WorkaroundsIf you just want to get IO working, I think that the file API on 0.2.2 required some hard to explain AsyncIO magic: import io/async
def process(fileName: String): Unit / {AsyncIO} = {
val promise = do read(fileName)
val contents: String = promise.block()
// ...
()
}
def main() = {
asyncIO(box { process("input") })
} It's somewhat more intuitive to do this on import io
import io/files
import io/error
def process(fileName: String): Unit / {Files} = {
val contents: String = do readFile(fileName)
// ...
()
}
// Note: the eventloop currently must be encompassing the whole program
def main() = eventloop(box {
with on[IOError].panic;
with filesystem;
process("input")
})
} |
do
-call after capability passing in v0.2.2
This comment was marked as outdated.
This comment was marked as outdated.
Yeah, in v0.2.2 just the import already produces the same crash: import io/file
def main() = () ... and if we minimise def await[T](p: Promise[T]): T / { IOException } =
try { awaitImpl(p){exc} } with exc : IOException[A] {
msg => do IOException(msg)
}
extern io def awaitImpl[T](p: Promise[T]){exc: IOException}: T =
"$effekt.callcc(k => ${p}.then(res => k($effekt.pure(res)), err => k(${box { (msg: String) => do IOException[T](msg) }}(err.message)))).then(c => c)"
// here instead of `do IOException`, we probably wanted to do `exc.IOException` instead!
// ... if you do that, the issue goes away completely :) |
OK, here's a very tiny version that still fails on effect IOException(msg: String): Nothing
extern io def three {exc: IOException}: Nothing =
js "${box { (msg: String) => do IOException(msg) }}('oops')}" with the original error message:
... which means that this is still a relevant bug, even though the I haven't been able to remove the weird indirection through FFI, but I'm running out of time and ideas :) |
do
-call after capability passing in v0.2.2do
-call in FFI after capability passing
During language exploration I ran into an unexpected compiler crash. The compiler (version: 0.2.2) always crashed when trying to compile the following code:
Stacktrace
Please don’t hesitate to reach out if any additional informations are required!
The text was updated successfully, but these errors were encountered: