Skip to content

Commit

Permalink
Unset FieldDef.optional if its key (google#6402)
Browse files Browse the repository at this point in the history
* Unset FieldDef.optional if its key

* removed StringKey table, just removed an extra "required, key"

* removed extra newline

Co-authored-by: Casper Neo <cneo@google.com>
  • Loading branch information
CasperN and Casper Neo committed Jan 12, 2021
1 parent 7abe612 commit 8573108
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 178 deletions.
1 change: 1 addition & 0 deletions src/idl_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Binary file modified tests/monster_test.bfbs
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/monster_test.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ table Monster {
pos:Vec3 (id: 0);
hp:short = 100 (id: 2);
mana:short = 150 (id: 1);
name:string (id: 3, required, key);
name:string (id: 3, key);
color:Color = Blue (id: 6);
inventory:[ubyte] (id: 5);
friendly:bool = false (deprecated, priority: 1, id: 4);
Expand Down
Loading

0 comments on commit 8573108

Please sign in to comment.