effekt-lang / effekt

A research language with effect handlers and lightweight effect polymorphism

Home Page:https://effekt-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`array::copy(from, start, to, offset, length)` copies one element more

marzipankaiser opened this issue · comments

According to the documentation:

/**
 * Copies `length`-many elements from `from` to `to`
 * starting at `start` (in `from`) and `offset` (in `to`)
 */
def copy[T](from: Array[T], start: Int, to: Array[T], offset: Int, length: Int): Unit / Exception[OutOfBounds]

However, actually:

import array

def main() = {
  with on[OutOfBounds].panic

  val a = array(10, 0)
  val b = array(10, 1)

  copy(a, 0, b, 0, 5)
  println(b)
}

consistently outputs:

Array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1)

(i.e., with 6 times 0 instead of 5) in all backends I tried.

Probably, here:

if (length >= 0) {

it should be > instead of >=.