tref_cast_error.nim 329 B

12345678910111213141516
  1. discard """
  2. cmd: "nim c --gc:arc $file"
  3. errormsg: "expression cannot be cast to 'ref RootObj'"
  4. joinable: false
  5. """
  6. type Variant* = object
  7. refval: ref RootObj
  8. proc newVariant*[T](val: T): Variant =
  9. let pt = T.new()
  10. pt[] = val
  11. result = Variant(refval: cast[ref RootObj](pt))
  12. var v = newVariant(@[1, 2, 3])