Using latest devel (a29387424a139505) array accessors appear not to be using user-defined converters. (It worked fine in nim 0.14.3 (2ac21261b4ab0ed) seq, openarray, string, cstring still work just fine.
type
Element = enum
FIRST
SECOND
THIRD
converter toInt*(x: Element): int = x.int
var data: array[3, int] = [1,2,3]
echo(data[SECOND.int]) # compile
#~echo(data[SECOND]) # doesn't compile
#~data[SECOND] = 4 # doesn't compile
the following procs can be used as a temporary workaround for that usecase.
proc `[]`[I: Ordinal, T](s: array[I, T], idx: enum): T =
result = s[idx.int]
proc `[]=`[I: Ordinal, T](s: var array[I, T], idx: enum, value: T) =
s[idx.int] = value
I also became aware of a new syntax which work quite well but appear to be missing something.
type
Element = enum
FIRST
SECOND
THIRD
var data: array[FIRST..THIRD, int] = [1,2,3]
echo(data[SECOND]) # compile
data[SECOND] = 4 # compile
echo(data[FIRST.int..THIRD.int]) # doesn't compile
echo(data[FIRST..THIRD]) # doesn't compile
The regression seems to appear in commit b78029b5afb3bfa69cf. (fixes #4626)
here is a testfile.
type
Element = enum
FIRST
SECOND
THIRD
converter toInt*(x: Element): int = x.int
var data = [1,2,3]
echo(data[SECOND])
data[SECOND] = 4