| 1 | struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc } |
| 2 | mut b := Bbb{} b = Bbb{Aaa{2}} |
| 3 | b.a.v = 1 // Error (field a immutable) |
| 4 | b.a = Aaa{} // Error (field a immutable) |
| 5 | ===output=== |
| 6 | cannot modify immutable field `a` (type `Bbb`) |
| 7 | declare the field with `mut:` |
| 8 | struct Bbb { |
| 9 | mut: |
| 10 | a Aaa |
| 11 | } |
| 12 | cannot modify immutable field `a` (type `Bbb`) |
| 13 | declare the field with `mut:` |
| 14 | struct Bbb { |
| 15 | mut: |
| 16 | a Aaa |
| 17 | } |
| 18 |