summary refs log tree commit diff stats
path: root/tests/notnil/tnotnil_in_objconstr.nim
blob: 471150f44625abb699af2a84058d2c065f404489 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
discard """
  errormsg: "The Foo type requires the following fields to be initialized: bar, baz"
  line: "17"
"""
{.experimental: "notnil".}
# bug #2355
type
  Base = object of RootObj
    baz: ref int not nil

  Foo = object of Base
    foo: ref int
    bar: ref int not nil

var x: ref int = new(int)
# Create instance without initializing the `bar` field
var f = Foo(foo: x)
echo f.bar.isNil # true