effekt-lang / effekt-lang/effekt
js runtime: `CAPTURE` drops the return value
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
When using `CAPTURE` in the javascript backend, this replaces the return value by `$effekt.unit`. Some of the existing FFI relies on this behavior (we then don't have to explicitly return unit):
https://github.com/effekt-lang/effekt/blob/fea824aa840891375c7cea198b38babfb3076338/libraries/js/effekt_runtime.js#L83-L89
### Example program
The following program triggers above behavior via [`promise.resolve`](https://github.com/effekt-lang/effekt/blob/fea824aa840891375c7cea198b38babfb3076338/libraries/common/io.effekt#L65-L66).
```effekt
import io
extern io def rT[T](run: => T at {io, async, global}): T =
js "$effekt.runToplevel((ks, k) => ${run}(ks, k))"
def main() = {
val pr = promise::make[Int]()
println(rT[Int](box {
pr.resolve(2);
12
}))
}
```
[Playground](https://effekt-lang.org/playground.html?playground=LY7NCoMwEITveYpFPCQgQj1a7L13b%2BIhtmtJzR9JKhbJu3eVnnZ3PmZ2lPEuJFCOMdwSBksrPHGG0A%2F9yMPHttDdoAeZYFeuAhm%2F9lHBS7tJ6ixaQh0DeEcoSpxnXFJNpt55jStqzpdYwSKOjHInkP%2BCKBg73hipLCcMO4WsUoMPdPjgjIrYtkYuONxtGrkg7oOySVtO3U5tctvpO0gdMDq9Im%2FE9ZQuDY0sBMs%2F&repl=bWFpbigp)
---
Thanks @b-studios for helping to find the underlying cause.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.