diff options
Diffstat (limited to 'v_windows/v/vlib/v/tests/repl/chained_fields')
5 files changed, 63 insertions, 0 deletions
diff --git a/v_windows/v/vlib/v/tests/repl/chained_fields/bd.repl.skip b/v_windows/v/vlib/v/tests/repl/chained_fields/bd.repl.skip new file mode 100644 index 0000000..8430f79 --- /dev/null +++ b/v_windows/v/vlib/v/tests/repl/chained_fields/bd.repl.skip @@ -0,0 +1,17 @@ +struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc } +mut b := Bbb{} b = Bbb{Aaa{2}} +b.a.v = 1 // Error (field a immutable) +b.a = Aaa{} // Error (field a immutable) +===output=== +cannot modify immutable field `a` (type `Bbb`) +declare the field with `mut:` +struct Bbb { +mut: + a Aaa +} +cannot modify immutable field `a` (type `Bbb`) +declare the field with `mut:` +struct Bbb { +mut: + a Aaa +} diff --git a/v_windows/v/vlib/v/tests/repl/chained_fields/c.repl.skip b/v_windows/v/vlib/v/tests/repl/chained_fields/c.repl.skip new file mode 100644 index 0000000..47cdde5 --- /dev/null +++ b/v_windows/v/vlib/v/tests/repl/chained_fields/c.repl.skip @@ -0,0 +1,17 @@ +struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc } +mut c := Ccc{} c.b = Bbb{} +c.b.a = Aaa{} // Error (field a immutable) +c.b.a.v = 1 // Error (field a immutable) +===output=== +cannot modify immutable field `a` (type `Bbb`) +declare the field with `mut:` +struct Bbb { +mut: + a Aaa +} +cannot modify immutable field `a` (type `Bbb`) +declare the field with `mut:` +struct Bbb { +mut: + a Aaa +} diff --git a/v_windows/v/vlib/v/tests/repl/chained_fields/c2.repl.skip b/v_windows/v/vlib/v/tests/repl/chained_fields/c2.repl.skip new file mode 100644 index 0000000..96e1da8 --- /dev/null +++ b/v_windows/v/vlib/v/tests/repl/chained_fields/c2.repl.skip @@ -0,0 +1,5 @@ +struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc } +c2 := Ccc{} +c2.b = Bbb{} // Error (c2 immutable) +===output=== +`c2` is immutable diff --git a/v_windows/v/vlib/v/tests/repl/chained_fields/d.repl.skip b/v_windows/v/vlib/v/tests/repl/chained_fields/d.repl.skip new file mode 100644 index 0000000..cf33384 --- /dev/null +++ b/v_windows/v/vlib/v/tests/repl/chained_fields/d.repl.skip @@ -0,0 +1,5 @@ +struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc } +mut d := Ddd{} d.c.b = Bbb{} +'OK' +===output=== +OK diff --git a/v_windows/v/vlib/v/tests/repl/chained_fields/ef.repl.skip b/v_windows/v/vlib/v/tests/repl/chained_fields/ef.repl.skip new file mode 100644 index 0000000..509218b --- /dev/null +++ b/v_windows/v/vlib/v/tests/repl/chained_fields/ef.repl.skip @@ -0,0 +1,19 @@ +struct E { mut: v []int } struct F { e []E } mut f := F{} +f.e << E{} // Error (field e immutable) +f.e[0].v << 1 // Error (field e immutable) +e := E{} +e.v << 1 // Error (e immutable) +===output=== +cannot modify immutable field `e` (type `F`) +declare the field with `mut:` +struct F { +mut: + e []E +} +cannot modify immutable field `e` (type `F`) +declare the field with `mut:` +struct F { +mut: + e []E +} +`e` is immutable (can't <<) |