More precise error messages for uninitialized fields in the presence of inheritance

This commit is contained in:
Zahary Karadjov 2020-03-29 19:05:01 +03:00 • committed by Andreas Rumpf
commit 7b7e42be54
3 changed files with 39 additions and 38 deletions

View file

@ -1,13 +1,17 @@
discard """
errormsg: "The Foo type requires the following fields to be initialized: bar"
line: "13"
errormsg: "The Foo type requires the following fields to be initialized: bar, baz"
line: "17"
"""
{.experimental: "notnil".}
# bug #2355
type
Foo = object
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)