Skip to content

Combining ref types with generics causes a compilation error #19

@zah

Description

@zah
import json
import json_serialization

type
  RpcResponse*[T] = ref object
    result*: T
    id*: int
    error*: string

when isMainModule:
  echo("Hello, World!")
  let jsn = %* {
    "result": "0x0",
    "id": 0
  }
  echo Json.decode($jsn, RpcResponse[string])

Error:

/usr/local/Cellar/nim/1.2.0/nim/lib/system.nim(850, 11) Error: invalid type: 'T' in this context: 'ref RpcResponse:ObjectType' for var

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions