diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index cce86a5d68..6699ae1fb8 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -272,6 +272,14 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { c.error('result type arguments are not supported', param.type_pos) } arg_typ_sym := c.table.sym(param.typ) + // resolve unresolved fixed array size e.g. [mod.const]array_type + if arg_typ_sym.info is ast.ArrayFixed + && c.array_fixed_has_unresolved_size(arg_typ_sym.info) { + mut size_expr := unsafe { arg_typ_sym.info.size_expr } + param.typ = c.eval_array_fixed_sizes(mut size_expr, 0, arg_typ_sym.info.elem_type) + mut v := node.scope.find_var(param.name) or { continue } + v.typ = param.typ + } if arg_typ_sym.info is ast.Struct { if !param.typ.is_ptr() && arg_typ_sym.info.is_heap { // set auto_heap to promote value parameter mut v := node.scope.find_var(param.name) or { continue } diff --git a/vlib/v/tests/fns/param_fixed_array_const_test.v b/vlib/v/tests/fns/param_fixed_array_const_test.v new file mode 100644 index 0000000000..41014609af --- /dev/null +++ b/vlib/v/tests/fns/param_fixed_array_const_test.v @@ -0,0 +1,12 @@ +module main + +import crypto.ed25519 + +fn new_client_hello(public_key [ed25519.public_key_size]u8) { + assert public_key.len == ed25519.public_key_size + assert public_key.len != 0 +} + +fn test_main() { + new_client_hello([ed25519.public_key_size]u8{}) +}