vxx2 / vlib / v / checker / tests / mut_receiver_lit.vv
25 lines · 21 sloc · 406 bytes · 3d8425dafdb0a4bd0f29df6b8604893c8f722456
Raw
1// error in non-mut as receover
2struct Box {
3mut:
4 value int
5}
6
7fn (mut box Box) set(value int) {
8 box.value = value
9}
10
11fn non_mut_receiver() {
12 Box{}.set(0)
13}
14
15// error in array chained method calls
16fn array_chained_method_calls() {
17 path := 'hello/file.txt'
18 _ = path.split('.').pop()
19}
20
21// error in map chained method calls
22fn map_chained_method_calls() {
23 mut m := map[int]int{}
24 m.clone().delete(0)
25}
26