v2 / vlib / v / slow_tests / repl / chained_fields / c.repl.skip
17 lines · 17 sloc · 433 bytes · 6a32c810703f4ec0c39fe18298ebe6c40acac8f1
Raw
1struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc }
2mut c := Ccc{} c.b = Bbb{}
3c.b.a = Aaa{} // Error (field a immutable)
4c.b.a.v = 1 // Error (field a immutable)
5===output===
6cannot modify immutable field `a` (type `Bbb`)
7declare the field with `mut:`
8struct Bbb {
9mut:
10 a Aaa
11}
12cannot modify immutable field `a` (type `Bbb`)
13declare the field with `mut:`
14struct Bbb {
15mut:
16 a Aaa
17}
18