From 1c629f4a93d8c9b536740f078e3f50ab536fbc14 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 15 Dec 2021 14:49:30 +0800 Subject: [PATCH] cgen: fix ci error of empty struct init (#12838) --- vlib/v/gen/c/cgen.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 6a5e4527ce..e164eeb640 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -6816,7 +6816,15 @@ fn (mut g Gen) type_default(typ_ ast.Type) string { } init_str += '.$field_name = $expr_str,' } else { - zero_str := g.type_default(field.typ) + mut zero_str := g.type_default(field.typ) + if zero_str == '{0}' { + if field_sym.info is ast.Struct && field_sym.language == .v { + if field_sym.info.fields.len == 0 + && field_sym.info.embeds.len == 0 { + zero_str = '{EMPTY_STRUCT_INITIALIZATION}' + } + } + } init_str += '.$field_name = $zero_str,' } has_none_zero = true