Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: check enum static from_string arguments errors (#19163)
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
vlib/v/checker/tests/enum_from_string_args_err.vv:8:2: error: expected 1 argument, but got 0 | ||
6 | | ||
7 | fn main() { | ||
8 | Color.from_string() | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
9 | Color.from_string('red', 'blue') | ||
10 | Color.from_string(22) | ||
vlib/v/checker/tests/enum_from_string_args_err.vv:9:2: error: expected 1 argument, but got 2 | ||
7 | fn main() { | ||
8 | Color.from_string() | ||
9 | Color.from_string('red', 'blue') | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
10 | Color.from_string(22) | ||
11 | Color.from_string(22.22) | ||
vlib/v/checker/tests/enum_from_string_args_err.vv:10:2: error: expected `string` argument, but got `int literal` | ||
8 | Color.from_string() | ||
9 | Color.from_string('red', 'blue') | ||
10 | Color.from_string(22) | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
11 | Color.from_string(22.22) | ||
12 | Color.from_string(true) | ||
vlib/v/checker/tests/enum_from_string_args_err.vv:11:2: error: expected `string` argument, but got `float literal` | ||
9 | Color.from_string('red', 'blue') | ||
10 | Color.from_string(22) | ||
11 | Color.from_string(22.22) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
12 | Color.from_string(true) | ||
13 | } | ||
vlib/v/checker/tests/enum_from_string_args_err.vv:12:2: error: expected `string` argument, but got `bool` | ||
10 | Color.from_string(22) | ||
11 | Color.from_string(22.22) | ||
12 | Color.from_string(true) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
enum Color { | ||
red | ||
green | ||
blue | ||
} | ||
|
||
fn main() { | ||
Color.from_string() | ||
Color.from_string('red', 'blue') | ||
Color.from_string(22) | ||
Color.from_string(22.22) | ||
Color.from_string(true) | ||
} |