From 7bb9c0e7b306c160d27d784c1029c4d7e9082508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=A4schle?= Date: Tue, 26 Jan 2021 08:37:48 +0100 Subject: [PATCH] checker: fix multi generic args (#8347) --- vlib/v/checker/check_types.v | 4 ++-- vlib/v/tests/generics_test.v | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index 0edee4c32a..0f786acb1e 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -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 diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index 77b3f75dd2..aec6945664 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -377,3 +377,12 @@ fn test_multi_return() { multi_return() multi_return() } + +fn multi_generic_args(t T, v V) bool { + return true +} + +fn test_multi_generic_args() { + assert multi_generic_args("Super", 2021) +} +