tnotnil_in_objconstr.nim 402 B

12345678910111213141516171819
  1. discard """
  2. errormsg: "The Foo type requires the following fields to be initialized: bar, baz"
  3. line: "17"
  4. """
  5. {.experimental: "notnil".}
  6. # bug #2355
  7. type
  8. Base = object of RootObj
  9. baz: ref int not nil
  10. Foo = object of Base
  11. foo: ref int
  12. bar: ref int not nil
  13. var x: ref int = new(int)
  14. # Create instance without initializing the `bar` field
  15. var f = Foo(foo: x)
  16. echo f.bar.isNil # true