checker: fix missing check generic fn call args (fix #10649) (#10657)

pull/10668/head
yuyi 2021-07-05 00:15:15 +08:00 committed by GitHub
parent 665279938e
commit b0b4b8e65b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 11 deletions

View File

@ -178,7 +178,7 @@ fn (vd VDoc) work_processor(mut work sync.Channel, mut wg sync.WaitGroup) {
fn (vd VDoc) render_parallel(out Output) {
vjobs := runtime.nr_jobs()
mut work := sync.new_channel<ParallelDoc>(vd.docs.len)
mut work := sync.new_channel<ParallelDoc>(u32(vd.docs.len))
mut wg := sync.new_waitgroup()
for i in 0 .. vd.docs.len {
p_doc := ParallelDoc{vd.docs[i], out}

View File

@ -2658,7 +2658,7 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
if typ_sym.kind == .void && param_typ_sym.kind == .string {
continue
}
if func.generic_names.len > 0 {
if param.typ.has_flag(.generic) {
continue
}
if c.pref.translated {

View File

@ -12,13 +12,6 @@ vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:27:7: error: <
| ~~
28 | handle(t)
29 | // println("${t.msg}")
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:28:9: error: cannot use `void` as `T` in argument 1 to `handle`
26 | fn g_worker(g Generic<T>) {
27 | t := <-g.ch
28 | handle(t)
| ^
29 | // println("${t.msg}")
30 | }
vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:1: error: generic function declaration must specify generic type names, e.g. foo<T>
30 | }
31 |

View File

@ -0,0 +1,7 @@
vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv:3:13: error: cannot use `[]rune` as `string` in argument 2 to `foo_str`
1 | fn main() {
2 | x := 'ab'.runes()[..1]
3 | foo_str(1, x)
| ^
4 | }
5 |

View File

@ -0,0 +1,7 @@
fn main() {
x := 'ab'.runes()[..1]
foo_str(1, x)
}
fn foo_str<T>(b T, a string) {
}

View File

@ -174,8 +174,8 @@ fn (mut tasks Tasks) run() {
vjobs := if tasks.parallel_jobs > 0 { tasks.parallel_jobs } else { runtime.nr_jobs() }
mut bench := benchmark.new_benchmark()
bench.set_total_expected_steps(tasks.all.len)
mut work := sync.new_channel<TaskDescription>(tasks.all.len)
mut results := sync.new_channel<TaskDescription>(tasks.all.len)
mut work := sync.new_channel<TaskDescription>(u32(tasks.all.len))
mut results := sync.new_channel<TaskDescription>(u32(tasks.all.len))
mut m_skip_files := skip_files.clone()
if os.getenv('V_CI_UBUNTU_MUSL').len > 0 {
m_skip_files << skip_on_ubuntu_musl