From 81e2ae803b36d38f547d789912c64183b88a9ff1 Mon Sep 17 00:00:00 2001 From: "M. Samil Atesoglu" Date: Mon, 26 Dec 2022 17:11:09 +0300 Subject: [PATCH] Do not complete missing fields in dynamic fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Can Oğuz --- src/idl_parser.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 49c937df29b..9e78dcca4ff 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -4520,27 +4520,10 @@ bool Parser::CompleteMissingField(FieldDef* absent_field, const StructDef &struc break; } } - if (auto typeName = LookupDynamicFieldType(absent_field, &struct_def)) + if (LookupDynamicFieldType(absent_field, &struct_def)) { - Type type; - if (ResolveDynamicType(typeName, type, absent_field)) - { - if (type.struct_def && !type.struct_def->fixed) - { - return true; - } - - // we want zero-initialized default pin data - Value val = absent_field->value; - std::vector empty(type.base_type == BASE_TYPE_STRING ? 1 : InlineSize(type)); - builder_.ForceVectorAlignment(empty.size(), sizeof(uint8_t), type.base_type == BASE_TYPE_STRING ? 1 : InlineAlignment(type)); - auto off = builder_.CreateVector(empty); - val.constant = NumToString(off.o); - - found = true; - fieldn_outer++; - field_stack_.insert(elem.base(), std::make_pair(val, absent_field)); - } + // Do not complete dynamic fields any more. + return true; } // auto-complete missing fields of a struct if (!found && struct_def.fixed)