v2 / vlib / v / checker / tests / struct_update_comptime_err.vv
32 lines · 25 sloc · 360 bytes · 09766c44b63f2edf9b7a101a4c23a8ae52f52cb8
Raw
1struct Aa {
2 sub Bb
3}
4
5struct AaWithAliasType {
6 sub Bb
7}
8
9type AliasType = Bb
10
11struct Bb {
12 a int
13}
14
15fn encode_struct[U](val U) {
16 $for field in U.fields {
17 _ = struct {
18 ...val.$(field.name)
19 }
20 }
21}
22
23fn main() {
24 aa := Aa{}
25 bb := Bb{}
26 aa_with_alias_type := AaWithAliasType{}
27
28 encode_struct(aa)
29 encode_struct(aa_with_alias_type)
30
31 encode_struct(bb)
32}
33