Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 30, 2024
1 parent d9e505b commit e51cce1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,12 @@ fn (mut c Checker) resolve_comptime_args(func &ast.Fn, node_ ast.CallExpr, concr
}
}
} else if call_arg.expr.obj.ct_type_var == .generic_var {
mut ctyp := c.type_resolver.get_type(call_arg.expr)
mut ctyp := c.unwrap_generic(c.type_resolver.get_type(call_arg.expr))
cparam_type_sym := c.table.sym(c.unwrap_generic(ctyp))
param_typ_sym := c.table.sym(param_typ)
if param_typ_sym.kind == .array && cparam_type_sym.info is ast.Array {
ctyp = cparam_type_sym.info.elem_type
}
if node_.args[i].expr.is_auto_deref_var() {
ctyp = ctyp.deref()
}
Expand Down
18 changes: 18 additions & 0 deletions vlib/v/tests/generics/generic_fn_array_infer_var_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fn function_that_receives_an_array_of_generic_type[T](array []T) {
return
}

fn function_that_returns_an_array_of_generic_type[T]() []T {
return []
}

fn func[T]() {
res := function_that_returns_an_array_of_generic_type[T]()
function_that_receives_an_array_of_generic_type(res)
function_that_receives_an_array_of_generic_type[T](res)
return
}

fn test_main() {
func[string]()
}

0 comments on commit e51cce1

Please sign in to comment.