1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/checker/tests/struct_update_comptime_err.vv
2023-01-03 10:21:32 +02:00

33 lines
360 B
V

struct Aa {
sub Bb
}
struct AaWithAliasType {
sub Bb
}
type AliasType = Bb
struct Bb {
a int
}
fn encode_struct[U](val U) {
$for field in U.fields {
_ = struct {
...val.$(field.name)
}
}
}
fn main() {
aa := Aa{}
bb := Bb{}
aa_with_alias_type := AaWithAliasType{}
encode_struct(aa)
encode_struct(aa_with_alias_type)
encode_struct(bb)
}