From 8573108bbef495f3dd13db8353f43b2e86d25950 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 12 Jan 2021 14:06:43 -0500 Subject: [PATCH] Unset FieldDef.optional if its key (#6402) * Unset FieldDef.optional if its key * removed StringKey table, just removed an extra "required, key" * removed extra newline Co-authored-by: Casper Neo --- src/idl_parser.cpp | 1 + tests/monster_test.bfbs | Bin 12744 -> 12704 bytes tests/monster_test.fbs | 2 +- tests/monster_test_bfbs_generated.h | 352 ++++++++++++++++++------------------ 4 files changed, 177 insertions(+), 178 deletions(-) diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 31d702f..0b10853 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -906,6 +906,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) { struct_def.has_key = true; if (!IsScalar(type.base_type)) { field->required = true; + field->optional = false; if (type.base_type != BASE_TYPE_STRING) return Error("'key' field must be string or scalar type"); } diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index 65bf49afde401f0c71830b99c93e767ada9925ee..ad26b97007d5a362b033423870dd1b0957d58fe0 100644 GIT binary patch delta 1508 zcmZWpZBUd|6u##!3oN@W%fhnkzPror^0C4e3k#uX4i+`bKq&@}iUq_v@)b>{HZ^4v zmCk7CfRD{IrVjpT)U2uShdR>_8*8*FMv}28U{ugp2NUpPM#kLkeW^j`N=-ON>B18sAB`c2SMWZc8d`}hd<9*>54@F@qd>Ee zwxd~7NT+Z>Q^k!JFsUi0N-T|0=nbrmQFv1hmTTFvbjGa54UWrZA{oO)uc_*ed$Gdxx-e0)ufG-1S>Gk8dH`i8kFPVK3`i zsSD311n4}rCirvS|1%oZu~e2Om?UY;e~iWb(WrE3gxOGB#Ezmj!3vW;E~r;sg+cbK zfW|TNJm~gmXo8H}BA`?7=&h(1P@Qx&3zv5w8r3r6Jm|$~XuJv)Dax@?K))8yI29^f zuM4P#CCr0n|DhHft3nHk**=`sTlW~^^jZ}uJl_w%=uZ{hCPQh`sp)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