diff options
Diffstat (limited to 'tests/notnil/tnotnil_in_objconstr.nim')
-rw-r--r-- | tests/notnil/tnotnil_in_objconstr.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/notnil/tnotnil_in_objconstr.nim b/tests/notnil/tnotnil_in_objconstr.nim new file mode 100644 index 000000000..471150f44 --- /dev/null +++ b/tests/notnil/tnotnil_in_objconstr.nim @@ -0,0 +1,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 |