1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: no notice for interface field initialized struct with ...other syntax (#18405)

This commit is contained in:
Swastik Baranwal 2023-06-11 22:33:20 +05:30 committed by GitHub
parent 2e9c469158
commit fc6726b2b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -660,7 +660,7 @@ fn (mut c Checker) struct_init(mut node ast.StructInit, is_field_zero_struct_ini
}
}
if !field.typ.has_flag(.option) && sym.kind == .interface_
&& (!has_noinit && sym.language != .js) {
&& (!has_noinit && sym.language != .js) && !node.has_update_expr {
// TODO: should be an error instead, but first `ui` needs updating.
c.note('interface field `${type_sym.name}.${field.name}` must be initialized',
node.pos)

View File

@ -0,0 +1,5 @@
[vlib/v/slow_tests/inout/interface_field_initialised_struct_update_expr.vv:20] o: Outer{
a: Foo(FooImpl{
prop: 0
})
}

View File

@ -0,0 +1,21 @@
interface Foo {
prop int
}
struct FooImpl {
prop int
}
struct Outer {
a Foo
}
fn main() {
other := Outer{
a: FooImpl{}
}
o := Outer{
...other
}
dump(o)
}