-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: disallow indexing mut struct, passed as a fn parameter (#19992)
- Loading branch information
Showing
5 changed files
with
57 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:12:9: warning: pointer indexing is only allowed in `unsafe` blocks | ||
10 | | ||
11 | _ = st1[0] | ||
12 | _ = st2[0] | ||
| ~~~ | ||
13 | _ = st3[0] | ||
14 | } | ||
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:8:9: error: type `Foo` does not support indexing | ||
6 | | ||
7 | fn sum_type_or_interface_as_parameters(mut foo Foo, mut bar Bar, mut st1 Struct, st2 &Struct, st3 Struct) { | ||
8 | _ = foo[0] | ||
| ~~~ | ||
9 | _ = bar[0] | ||
10 | | ||
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:9:9: error: type `Bar` does not support indexing | ||
7 | fn sum_type_or_interface_as_parameters(mut foo Foo, mut bar Bar, mut st1 Struct, st2 &Struct, st3 Struct) { | ||
8 | _ = foo[0] | ||
9 | _ = bar[0] | ||
| ~~~ | ||
10 | | ||
11 | _ = st1[0] | ||
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:11:9: error: type `mut Struct` does not support slicing | ||
9 | _ = bar[0] | ||
10 | | ||
11 | _ = st1[0] | ||
| ~~~ | ||
12 | _ = st2[0] | ||
13 | _ = st3[0] | ||
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv:13:9: error: type `Struct` does not support indexing | ||
11 | _ = st1[0] | ||
12 | _ = st2[0] | ||
13 | _ = st3[0] | ||
| ~~~ | ||
14 | } |
14 changes: 14 additions & 0 deletions
14
vlib/v/checker/tests/index_sumtype_interface_struct_params_err.vv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
type Foo = int | map[int]int | ||
|
||
interface Bar {} | ||
|
||
struct Struct {} | ||
|
||
fn sum_type_or_interface_as_parameters(mut foo Foo, mut bar Bar, mut st1 Struct, st2 &Struct, st3 Struct) { | ||
_ = foo[0] | ||
_ = bar[0] | ||
|
||
_ = st1[0] | ||
_ = st2[0] | ||
_ = st3[0] | ||
} |
13 changes: 0 additions & 13 deletions
13
vlib/v/checker/tests/index_sumtype_or_interface_params_err.out
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
vlib/v/checker/tests/index_sumtype_or_interface_params_err.vv
This file was deleted.
Oops, something went wrong.