Skip to content

Commit

Permalink
JS backend: Do not drop first element for Array.toList (fixes #319) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
b-studios authored Nov 28, 2023
2 parents e68b8b3 + fb5a6b5 commit 7f9e654
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions effekt/jvm/src/test/scala/effekt/ChezSchemeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class ChezSchemeTests extends EffektTests {
examplesDir / "ml",

examplesDir / "pos" / "arrays.effekt",
examplesDir / "pos" / "issue319.effekt",
examplesDir / "pos" / "maps.effekt",

// bidirectional effects are not yet supported in our Chez backend
Expand Down
1 change: 1 addition & 0 deletions effekt/jvm/src/test/scala/effekt/MLTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class MLTests extends EffektTests {

// array api
examplesDir / "pos" / "raytracer.effekt",
examplesDir / "pos" / "issue319.effekt",

// async
examplesDir / "pos" / "io" / "async_file_io.effekt",
Expand Down
1 change: 1 addition & 0 deletions examples/pos/issue319.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cons(1, Cons(2, Cons(3, Nil())))
6 changes: 6 additions & 0 deletions examples/pos/issue319.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import mutable/array

def main() = {
val array = arrayFromList([1,2,3]);
println(array.toList)
}
2 changes: 1 addition & 1 deletion libraries/js/mutable/array.effekt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern pure def copy[T](arr: Array[T]): Array[T] =
def toList[T](arr: Array[T]): List[T] = {
var i = arr.size - 1;
var l = Nil[T]()
while (i > 0) {
while (i >= 0) {
l = Cons(unsafeGet(arr, i), l)
i = i - 1
}
Expand Down

0 comments on commit 7f9e654

Please sign in to comment.