Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast, checker: add a notice, for accessing by key, map values, that co…
…ntain pointers (to use unsafe or an `or {}` block) (#20266)
- Loading branch information
Showing
10 changed files
with
110 additions
and
30 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
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
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
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
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 |
---|---|---|
@@ -1,14 +1,34 @@ | ||
vlib/v/checker/tests/map_index_reference_value.vv:7:3: notice: accessing a pointer map value requires an `or {}` block outside `unsafe` | ||
5 | fn main() { | ||
6 | mut m := map[string]&Foo{} | ||
7 | m['bar'].bar = 'bar' | ||
vlib/v/checker/tests/map_index_reference_value.vv:11:3: notice: accessing a pointer map value requires an `or {}` block outside `unsafe` | ||
9 | fn main() { | ||
10 | mut m := map[string]&Foo{} | ||
11 | m['bar'].bar = 'bar' | ||
| ~~~~~~~ | ||
8 | // m['bar'] << 'baz' // etc | ||
9 | } | ||
vlib/v/checker/tests/map_index_reference_value.vv:7:11: error: field `bar` of struct `&Foo` is immutable | ||
5 | fn main() { | ||
6 | mut m := map[string]&Foo{} | ||
7 | m['bar'].bar = 'bar' | ||
12 | // m['bar'] << 'baz' // etc | ||
13 | | ||
vlib/v/checker/tests/map_index_reference_value.vv:11:3: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` | ||
9 | fn main() { | ||
10 | mut m := map[string]&Foo{} | ||
11 | m['bar'].bar = 'bar' | ||
| ~~~~~~~ | ||
12 | // m['bar'] << 'baz' // etc | ||
13 | | ||
vlib/v/checker/tests/map_index_reference_value.vv:15:8: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` | ||
13 | | ||
14 | mut m2 := map[string]Bar{} | ||
15 | _ = m2['key'] | ||
| ~~~~~~~ | ||
16 | | ||
17 | mut m3 := map[string][]Bar{} | ||
vlib/v/checker/tests/map_index_reference_value.vv:18:8: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe` | ||
16 | | ||
17 | mut m3 := map[string][]Bar{} | ||
18 | _ = m3['key'] | ||
| ~~~~~~~ | ||
19 | } | ||
vlib/v/checker/tests/map_index_reference_value.vv:11:11: error: field `bar` of struct `&Foo` is immutable | ||
9 | fn main() { | ||
10 | mut m := map[string]&Foo{} | ||
11 | m['bar'].bar = 'bar' | ||
| ~~~ | ||
8 | // m['bar'] << 'baz' // etc | ||
9 | } | ||
12 | // m['bar'] << 'baz' // etc | ||
13 | |
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
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
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
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
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