Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 8, 2024
1 parent 80128f6 commit 3dfa775
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
26 changes: 26 additions & 0 deletions vlib/v/tests/fns/param_fixed_array_const_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module main

import crypto.ed25519

struct SSHClientHello {
version u8
public_key [crypto.ed25519.public_key_size]u8

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / clang (macos-14)

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / gcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / code-formatting

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / clang

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / msvc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / alpine-docker-musl-gcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-address-clang

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-memory-clang

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / gcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / ubuntu-docker-musl

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-undefined-clang

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-address-gcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-undefined-gcc

fixed array size cannot use non-constant value

Check failure on line 7 in vlib/v/tests/fns/param_fixed_array_const_test.v

View workflow job for this annotation

GitHub Actions / tests-sanitize-address-msvc

fixed array size cannot use non-constant value
}

struct SSHServerHello {
version u8
send_me [crypto.ed25519.public_key_size]u8
}

struct SSHClientProof {
result [crypto.ed25519.public_key_size]u8
}

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{})
}

0 comments on commit 3dfa775

Please sign in to comment.