1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix multi generic args (#8347)

This commit is contained in:
Daniel Däschle 2021-01-26 08:37:48 +01:00 committed by GitHub
parent 69c37402d4
commit 7bb9c0e7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -429,12 +429,12 @@ pub fn (mut c Checker) infer_fn_types(f table.Fn, mut call_expr ast.CallExpr) {
} else {
call_expr.args[i]
}
if param.typ.has_flag(.generic) {
param_type_sym := c.table.get_type_symbol(param.typ)
if param.typ.has_flag(.generic) && param_type_sym.name == gt_name {
typ = arg.typ
break
}
arg_sym := c.table.get_type_symbol(arg.typ)
param_type_sym := c.table.get_type_symbol(param.typ)
if arg_sym.kind == .array && param_type_sym.kind == .array {
mut arg_elem_info := arg_sym.info as table.Array
mut param_elem_info := param_type_sym.info as table.Array

View File

@ -377,3 +377,12 @@ fn test_multi_return() {
multi_return<Foo1, Foo2>()
multi_return<Foo3, Foo4>()
}
fn multi_generic_args<T, V>(t T, v V) bool {
return true
}
fn test_multi_generic_args() {
assert multi_generic_args("Super", 2021)
}