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:
parent
2e9c469158
commit
fc6726b2b1
@ -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_
|
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.
|
// TODO: should be an error instead, but first `ui` needs updating.
|
||||||
c.note('interface field `${type_sym.name}.${field.name}` must be initialized',
|
c.note('interface field `${type_sym.name}.${field.name}` must be initialized',
|
||||||
node.pos)
|
node.pos)
|
||||||
|
@ -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)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user