Skip to content

Commit

Permalink
checker: no notice for interface field initialized struct with `...…
Browse files Browse the repository at this point in the history
…other` syntax (#18405)
  • Loading branch information
Delta456 committed Jun 11, 2023
1 parent 2e9c469 commit fc6726b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/struct.v
Expand Up @@ -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)
Expand Down
@@ -0,0 +1,5 @@
[vlib/v/slow_tests/inout/interface_field_initialised_struct_update_expr.vv:20] o: Outer{
a: Foo(FooImpl{
prop: 0
})
}
@@ -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)
}

0 comments on commit fc6726b

Please sign in to comment.