mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: check array.sort_with_compare() arg mismatch (#11385)
This commit is contained in:
15
vlib/v/checker/tests/array_sort_with_compare_err.out
Normal file
15
vlib/v/checker/tests/array_sort_with_compare_err.out
Normal file
@@ -0,0 +1,15 @@
|
||||
vlib/v/checker/tests/array_sort_with_compare_err.vv:4:26: error: cannot use `fn (string, string) int` as `fn (voidptr, voidptr) int` in argument 1 to `[]string.sort_with_compare`
|
||||
2 | mut names := ['aaa', 'bbb', 'ccc']
|
||||
3 |
|
||||
4 | names.sort_with_compare(sort_by_file_base)
|
||||
| ~~~~~~~~~~~~~~~~~
|
||||
5 | println(names)
|
||||
6 |
|
||||
Details: ``'s expected fn argument: `` is a pointer, but the passed fn argument: `a` is NOT a pointer
|
||||
vlib/v/checker/tests/array_sort_with_compare_err.vv:7:26: error: cannot use `int literal` as `fn (voidptr, voidptr) int` in argument 1 to `[]string.sort_with_compare`
|
||||
5 | println(names)
|
||||
6 |
|
||||
7 | names.sort_with_compare(22)
|
||||
| ~~
|
||||
8 | println(names)
|
||||
9 | }
|
||||
13
vlib/v/checker/tests/array_sort_with_compare_err.vv
Normal file
13
vlib/v/checker/tests/array_sort_with_compare_err.vv
Normal file
@@ -0,0 +1,13 @@
|
||||
fn main() {
|
||||
mut names := ['aaa', 'bbb', 'ccc']
|
||||
|
||||
names.sort_with_compare(sort_by_file_base)
|
||||
println(names)
|
||||
|
||||
names.sort_with_compare(22)
|
||||
println(names)
|
||||
}
|
||||
|
||||
fn sort_by_file_base(a string, b string) int {
|
||||
return int(a > b)
|
||||
}
|
||||
Reference in New Issue
Block a user