Hello i have the following function in nim from a c-api (converted by c2nim):
    
    
    proc highlighterHook(input: cstring, colors: ptr ReplxxColor,
                                          size: cint, userData: pointer) 
{.cdecl.} =
       for idx, item in input:
          if isDigit($input[idx]):
             colors[idx] = REPLXX_COLOR_MAGENTA
    
    
    Run

In this function colors: ptr ReplxxColor is an array of colors.

I want to access it like an array using colors[idx] = myColor

I have the following error:
    
    
    ... albinospkg/cli.nim(163, 10) Warning: Deprecated since version 0.20 
since its semantics are unclear; isDigit is deprecated [Deprecated]
            ... albinospkg/cli.nim(164, 16) Error: type mismatch: got <ptr 
ReplxxColor, int, ReplxxColor>
            ... but expected one of:
            ... proc `[]=`[A, B](t: TableRef[A, B]; key: A; val: B)
            ... proc `[]=`(headers: HttpHeaders; key, value: string)
            ... proc `[]=`(p: var MultipartData; name: string;
            ...           file: tuple[name, contentType, content: string])
            ... proc `[]=`(x: Any; fieldName: string; value: Any)
            ... proc `[]=`[T, U, V](s: var seq[T]; x: HSlice[U, V]; b: 
openArray[T])
            ... proc `[]=`[A](t: CountTableRef[A]; key: A; val: int)
            ... template `[]=`(s: string; i: int; val: char)
            ... proc `[]=`(headers: HttpHeaders; key: string; value: 
seq[string])
            ... proc `[]=`(obj: JsonNode; key: string; val: JsonNode)
            ... proc `[]=`(x, y: Any)
            ... proc `[]=`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex; x: 
T)
            ... proc `[]=`(s: var string; i: BackwardsIndex; x: char)
            ... proc `[]=`(n: NimNode; i: int; child: NimNode)
            ... proc `[]=`[Idx, T, U, V](a: var array[Idx, T]; x: HSlice[U, V]; 
b: openArray[T])
            ... proc `[]=`[T](s: var openArray[T]; i: BackwardsIndex; x: T)
            ... proc `[]=`[A, B](t: var OrderedTable[A, B]; key: A; val: B)
            ... proc `[]=`[A](t: var CountTable[A]; key: A; val: int)
            ... proc `[]=`(x: Any; i: int; y: Any)
            ... proc `[]=`(p: var MultipartData; name, content: string)
            ... proc `[]=`[T, U](s: var string; x: HSlice[T, U]; b: string)
            ... proc `[]=`(n: NimNode; i: BackwardsIndex; child: NimNode)
            ... proc `[]=`[A, B](t: OrderedTableRef[A, B]; key: A; val: B)
            ... proc `[]=`[A, B](t: var Table[A, B]; key: A; val: B)
            ... proc `[]=`[I: Ordinal; T, S](a: T; i: I; x: S)
            ... expression: []=(colors, idx, REPLXX_COLOR_MAGENTA)
    
    
    Run

Reply via email to