Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: disallow assigning mutable reference to immutable ParExpr (#…
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 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
7 changes: 7 additions & 0 deletions
7
vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_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,7 @@ | ||
vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_err.vv:10:11: error: `a_char` is immutable, cannot have a mutable reference to it | ||
8 | | ||
9 | fn foo() { | ||
10 | mut c := &(a_char) | ||
| ^ | ||
11 | println(c) | ||
12 | } |
12 changes: 12 additions & 0 deletions
12
vlib/v/checker/tests/assign_immutable_reference_var_with_parenthesis_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,12 @@ | ||
struct MyChar { | ||
c string | ||
} | ||
|
||
const a_char = MyChar{ | ||
c: 'a' | ||
} | ||
|
||
fn foo() { | ||
mut c := &(a_char) | ||
println(c) | ||
} |