summary refs log tree commit diff stats
path: root/tests/arc/tref_cast_error.nim
blob: b0d2faf771583828491063162e200fdb5483e351 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
discard """
  cmd: "nim c --gc:arc $file"
  errormsg: "expression cannot be cast to ref RootObj"
  joinable: false
"""

type Variant* = object
    refval: ref RootObj

proc newVariant*[T](val: T): Variant =
    let pt = T.new()
    pt[] = val
    result = Variant(refval: cast[ref RootObj](pt))

var v = newVariant(@[1, 2, 3])