You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BackwardsIndex [^i] on a ref array will fail to compile inside procedures, iterators, funcs, and methods. It will compile if you dereference the array explicitly, but this is contrary to the behavior of normal indices, as well as backwards indices outside a proc.
Error: type mismatch: got <ref array[0..0, int], BackwardsIndex>
but expected one of:
proc `[]`(s: string; i: BackwardsIndex): char
first type mismatch at position: 0
proc `[]`[I: Ordinal; T](a: T; i: I): T
first type mismatch at position: 0
proc `[]`[Idx, T, U, V](a: array[Idx, T]; x: HSlice[U, V]): seq[T]
first type mismatch at position: 0
proc `[]`[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T
first type mismatch at position: 0
proc `[]`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T
first type mismatch at position: 0
proc `[]`[T, U, V](s: openArray[T]; x: HSlice[U, V]): seq[T]
first type mismatch at position: 0
proc `[]`[T, U](s: string; x: HSlice[T, U]): string
first type mismatch at position: 0
proc `[]`[T](s: openArray[T]; i: BackwardsIndex): T
first type mismatch at position: 0
proc `[]`[T](s: var openArray[T]; i: BackwardsIndex): var T
first type mismatch at position: 0
template `[]`(s: string; i: int): char
first type mismatch at position: 0
expression: `[]`(arr, BackwardsIndex(1))
Nim Compiler Version 1.4.4 [Windows: amd64]
Compiled at 2021-02-23
Copyright (c) 2006-2020 by Andreas Rumpf
The text was updated successfully, but these errors were encountered:
The solution here wouldn't be in the compiler though, BackwardsIndex which is implemented in user code just isn't implemented for ref array, for which normal indexing happens to work
BackwardsIndex
[^i]
on aref array
will fail to compile inside procedures, iterators, funcs, and methods. It will compile if you dereference the array explicitly, but this is contrary to the behavior of normal indices, as well as backwards indices outside a proc.Example
Error
The text was updated successfully, but these errors were encountered: