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

checker: fix generic argument resolution for multiple generic args (#18073)

This commit is contained in:
Felipe Pena 2023-04-28 11:06:28 -03:00 committed by GitHub
parent b6bbd2463c
commit 2f48288a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View File

@ -1014,8 +1014,8 @@ fn (mut c Checker) infer_fn_generic_types(func ast.Fn, mut node ast.CallExpr) {
&& c.table.cur_fn.params.len > 0 && func.generic_names.len > 0
&& arg.expr is ast.Ident {
var_name := (arg.expr as ast.Ident).name
for cur_param in c.table.cur_fn.params {
if !cur_param.typ.has_flag(.generic) || cur_param.name != var_name {
for k, cur_param in c.table.cur_fn.params {
if !cur_param.typ.has_flag(.generic) || k < gi || cur_param.name != var_name {
continue
}
typ = cur_param.typ

View File

@ -0,0 +1,24 @@
struct App {
}
struct Config[T] {
val T
}
fn pre_start[T, R](app T, config R) string {
return start(app, config.val)
}
fn start[T, R](app T, otherthing R) R {
println(otherthing)
return otherthing
}
fn test_main() {
app := App{}
testval := 'hello'
config := Config[string]{
val: testval
}
assert pre_start(app, config) == 'hello'
}