sitory contains the Nim compiler, Nim's stdlib, tools, and documentation. (mirror)
summary refs log blame commit diff stats
path: root/tests/init/toutparam_subtype.nim
blob: 3597f1459badb658983b7ccb2c6da8b66d0d287a (plain) (tree)























                                                     
discard """
cmd: "nim check $file"
action: "compile"
errormsg: "type mismatch: got <Subclass[system.int]>"
line: 21
"""

{.experimental: "strictDefs".}

type
  Superclass[T] = object of RootObj
    a: T
  Subclass[T] = object of Superclass[T]
    s: string

proc init[T](x: out Superclass[T]) =
  x = Superclass(a: 8)

proc subtypeCheck =
  var v: Subclass[int]
  init(v)
  echo v.s # the 's' field was never initialized!

subtypeCheck()