From 33a2d00445cb2a1e60ce4947337730152be6b4d4 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 1 Jun 2022 21:56:12 +0800 Subject: [PATCH] cgen: fix fixed array of aliases struct (#14583) --- vlib/v/gen/c/cgen.v | 2 +- vlib/v/tests/fixed_array_of_alias_struct_test.v | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/fixed_array_of_alias_struct_test.v diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 035ecaf67a..a971ec20ac 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -5070,7 +5070,7 @@ fn (mut g Gen) sort_structs(typesa []&ast.TypeSymbol) []&ast.TypeSymbol { mut field_deps := []string{} match sym.info { ast.ArrayFixed { - dep := g.table.sym(sym.info.elem_type).name + dep := g.table.final_sym(sym.info.elem_type).name if dep in type_names { field_deps << dep } diff --git a/vlib/v/tests/fixed_array_of_alias_struct_test.v b/vlib/v/tests/fixed_array_of_alias_struct_test.v new file mode 100644 index 0000000000..6b90245435 --- /dev/null +++ b/vlib/v/tests/fixed_array_of_alias_struct_test.v @@ -0,0 +1,11 @@ +type Sfxinfo_t = Sfxinfo_struct + +struct Sfxinfo_struct { + name [9]i8 +} + +fn test_fixed_array_of_alias_struct() { + a := [5]Sfxinfo_t{} + println(a) + assert true +}