v icon indicating copy to clipboard operation
v copied to clipboard

nested auto initialized struct with required attribute doesn't give an error

Open danieldaeschle opened this issue 3 years ago • 0 comments

OS: WSL2 Ubuntu 20.04

What did you do?

struct Foo {
	bar Bar
}
struct Bar {
	egg Egg
}

struct Egg {
	name string [required]
}

fn main() {
	f := Foo{}
	println(f)
}

What did you expect to see? Foo contains a value that needs manual initialization (error)

What did you see instead? it compiles and prints

Foo{
    bar: Bar{
        egg: Egg{
            name: ''
        }
    }
}

similar problem described here: https://github.com/vlang/v/issues/10823

danieldaeschle avatar Jul 22 '21 14:07 danieldaeschle