I'm trying to get a slice from an open array and there seems to be a type mismatch error. Is there any way around this?
proc xxx(r: openarray[int]) =
processRow(r[0..9]) <- type mismatch
...
Please provide minimal, but complete examples when possible. This works fine:
proc processRow(r: openarray[int]) =
for i in r: echo i
proc xxx(r: openarray[int]) =
processRow(r[0..9])
xxx([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
Well, works fine with recent nim compiler:
nim -v
Nim Compiler Version 0.17.3 [Linux: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf
git hash: b7e69e7cbbf6139316841bcc7c596e93ac78d994
active boot switches: -d:release
Pressing the run button in forum gives:
Hint: used config file '/nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: in [Processing]
in.nim(5, 15) Error: type mismatch: got (openarray[int], Slice[system.int])
but expected one of:
proc `[]`(s: string; x: Slice[int]): string
proc `[]`[T](s: seq[T]; x: Slice[int]): seq[T]
proc `[]`[I: Ordinal; T](a: T; i: I): T
proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[Idx]): seq[T]
proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[int]): seq[T]