Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: add int signedness mismatch checking for function call argum…
…ents (#16750)
- Loading branch information
Showing
6 changed files
with
67 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
vlib/v/checker/tests/int_signess_call_arg_test.vv:5:8: error: cannot use `int` as `u64` in argument 1 to `ztest` | ||
3 | fn test_main(){ | ||
4 | a := -1 | ||
5 | ztest(a) | ||
| ^ | ||
6 | ztest2(-1) | ||
7 | ztest3(-1) | ||
vlib/v/checker/tests/int_signess_call_arg_test.vv:6:9: error: cannot use literal signed integer as `u8` in argument 1 to `ztest2` | ||
4 | a := -1 | ||
5 | ztest(a) | ||
6 | ztest2(-1) | ||
| ~~ | ||
7 | ztest3(-1) | ||
8 | ztest4(-1) | ||
vlib/v/checker/tests/int_signess_call_arg_test.vv:7:9: error: cannot use literal signed integer as `u16` in argument 1 to `ztest3` | ||
5 | ztest(a) | ||
6 | ztest2(-1) | ||
7 | ztest3(-1) | ||
| ~~ | ||
8 | ztest4(-1) | ||
9 | ztest5(-1) | ||
vlib/v/checker/tests/int_signess_call_arg_test.vv:8:9: error: cannot use literal signed integer as `u32` in argument 1 to `ztest4` | ||
6 | ztest2(-1) | ||
7 | ztest3(-1) | ||
8 | ztest4(-1) | ||
| ~~ | ||
9 | ztest5(-1) | ||
10 | } | ||
vlib/v/checker/tests/int_signess_call_arg_test.vv:9:9: error: cannot use literal signed integer as `usize` in argument 1 to `ztest5` | ||
7 | ztest3(-1) | ||
8 | ztest4(-1) | ||
9 | ztest5(-1) | ||
| ~~ | ||
10 | } | ||
11 | |
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 @@ | ||
module main | ||
|
||
fn test_main(){ | ||
a := -1 | ||
ztest(a) | ||
ztest2(-1) | ||
ztest3(-1) | ||
ztest4(-1) | ||
ztest5(-1) | ||
} | ||
|
||
fn ztest(len u64){println(len)} | ||
fn ztest2(len u8){println(len)} | ||
fn ztest3(len u16){println(len)} | ||
fn ztest4(len u32){println(len)} | ||
fn ztest5(len usize){println(len)} |