mirror of
https://github.com/vlang/v.git
synced 2025-09-11 00:20:26 -04:00
This commit is contained in:
parent
bf8ea4b594
commit
6ffc9c94b5
@ -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 }
|
||||
|
12
vlib/v/tests/fns/param_fixed_array_const_test.v
Normal file
12
vlib/v/tests/fns/param_fixed_array_const_test.v
Normal file
@ -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{})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user