effekt-lang / effekt-lang/effekt
Miscompilation of closure capture on JS
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
The following program (v1) is miscomplied on JS, whereas v2 is compiled correctly.
This likely has something to do with contification / the direct-style transform on JS as Chez-CPS seems to be correct.
```scala
def main() = {
var adders = []
each(1, 4) { x =>
println(x) // <- this line only on v1
// println(s"debug ${x.show}") // <- this line only on v2
adders = Cons(box { (y: Int) => y + x }, adders)
}
adders.foreach { adder =>
println(adder(3))
}
}
```
```sh
bash-5.3$ effekt --backend=js v1.effekt v2.effekt
1
2
3
7
7
7
debug 1
debug 2
debug 3
6
5
4
bash-5.3$ effekt --backend=llvm v1.effekt v2.effekt
1
2
3
6
5
4
debug 1
debug 2
debug 3
6
5
4
bash-5.3$ effekt --backend=chez-cps v1.effekt v2.effekt
1
2
3
6
5
4
debug 1
debug 2
debug 3
6
5
4
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.