Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: add error for
x as Y.field
, suggesting using `(x as Y).fie…
…ld` instead for clarity (#20725)
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
vlib/v/checker/tests/as_cast_selector_expr_err.vv:15:14: error: indeterminate `as` cast, use parenthesis to clarity | ||
13 | fn main() { | ||
14 | mut bar := Foobar(Bar{y: 123}) | ||
15 | println(bar as Bar.y == 123) | ||
| ~~ | ||
16 | } | ||
Details: for example `(bar as main.Bar).y` |
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,16 @@ | ||
struct Foo { | ||
mut: | ||
x int | ||
} | ||
|
||
struct Bar { | ||
mut: | ||
y int | ||
} | ||
|
||
type Foobar = Foo | Bar | ||
|
||
fn main() { | ||
mut bar := Foobar(Bar{y: 123}) | ||
println(bar as Bar.y == 123) | ||
} |
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 |
---|---|---|
|
@@ -14,5 +14,5 @@ fn test_main() { | |
mut bar := Foobar(Bar{ | ||
y: 123 | ||
}) | ||
assert bar as Bar.y == 123 | ||
assert (bar as Bar).y == 123 | ||
} |