| 1 | vlib/v/checker/tests/immutable_to_mutable_err.vv:15:20: notice: condition is always true |
| 2 | 13 | fn main() { |
| 3 | 14 | arr := [1, 2, 3] // declared as immutable! |
| 4 | 15 | mut arr_mut := if true { arr } else { []int{} } |
| 5 | | ~~~~ |
| 6 | 16 | mut arr_mut2 := match true { |
| 7 | 17 | true { arr } |
| 8 | vlib/v/checker/tests/immutable_to_mutable_err.vv:15:27: notice: left-side of assignment expects a mutable reference, but variable `arr` is immutable, declare it with `mut` to make it mutable or clone it |
| 9 | 13 | fn main() { |
| 10 | 14 | arr := [1, 2, 3] // declared as immutable! |
| 11 | 15 | mut arr_mut := if true { arr } else { []int{} } |
| 12 | | ~~~ |
| 13 | 16 | mut arr_mut2 := match true { |
| 14 | 17 | true { arr } |
| 15 | vlib/v/checker/tests/immutable_to_mutable_err.vv:17:3: notice: match is always true |
| 16 | 15 | mut arr_mut := if true { arr } else { []int{} } |
| 17 | 16 | mut arr_mut2 := match true { |
| 18 | 17 | true { arr } |
| 19 | | ~~~~ |
| 20 | 18 | else { [0] } |
| 21 | 19 | } |
| 22 | vlib/v/checker/tests/immutable_to_mutable_err.vv:17:10: notice: left-side of assignment expects a mutable reference, but variable `arr` is immutable, declare it with `mut` to make it mutable or clone it |
| 23 | 15 | mut arr_mut := if true { arr } else { []int{} } |
| 24 | 16 | mut arr_mut2 := match true { |
| 25 | 17 | true { arr } |
| 26 | | ~~~ |
| 27 | 18 | else { [0] } |
| 28 | 19 | } |
| 29 | vlib/v/checker/tests/immutable_to_mutable_err.vv:27:15: error: use `mut array2 := array1.clone()` instead of `mut array2 := array1` (or use `unsafe`) |
| 30 | 25 | |
| 31 | 26 | a := Test{} |
| 32 | 27 | mut arr_mut3 := a.foo |
| 33 | | ~~ |
| 34 | 28 | arr_mut3[0] = 999 |
| 35 | 29 | assert a.foo == [1, 2, 3] |
| 36 | vlib/v/checker/tests/immutable_to_mutable_err.vv:31:15: error: use `mut array2 := array1.clone()` instead of `mut array2 := array1` (or use `unsafe`) |
| 37 | 29 | assert a.foo == [1, 2, 3] |
| 38 | 30 | |
| 39 | 31 | mut arr_mut4 := a.bar |
| 40 | | ~~ |
| 41 | 32 | arr_mut4[0] = 999 |
| 42 | 33 | assert a.bar == [1, 2, 3] |
| 43 | vlib/v/checker/tests/immutable_to_mutable_err.vv:39:5: error: `s2.list` aliases mutable data from an immutable value, clone it first (or use `unsafe`) |
| 44 | 37 | } |
| 45 | 38 | mut s2 := s |
| 46 | 39 | s2.list[0] = 'bbb' |
| 47 | | ~~~~ |
| 48 | 40 | |
| 49 | 41 | _ := a.bar |
| 50 | |