mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 19:58:17 +00:00
Updated SupportsAdvancedUnionFeatures to look out for string (#6190)
Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -438,6 +438,10 @@ struct EnumDef : public Definition {
|
|||||||
SymbolTable<EnumVal> vals;
|
SymbolTable<EnumVal> vals;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool IsString(const Type &type) {
|
||||||
|
return type.base_type == BASE_TYPE_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool IsStruct(const Type &type) {
|
inline bool IsStruct(const Type &type) {
|
||||||
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
|
return type.base_type == BASE_TYPE_STRUCT && type.struct_def->fixed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2998,8 +2998,8 @@ CheckedError Parser::ParseRoot(const char *source, const char **include_paths,
|
|||||||
for (auto val_it = enum_def.Vals().begin();
|
for (auto val_it = enum_def.Vals().begin();
|
||||||
val_it != enum_def.Vals().end(); ++val_it) {
|
val_it != enum_def.Vals().end(); ++val_it) {
|
||||||
auto &val = **val_it;
|
auto &val = **val_it;
|
||||||
if (!SupportsAdvancedUnionFeatures() && val.union_type.struct_def &&
|
if (!SupportsAdvancedUnionFeatures() &&
|
||||||
val.union_type.struct_def->fixed)
|
(IsStruct(val.union_type) || IsString(val.union_type)))
|
||||||
return Error(
|
return Error(
|
||||||
"only tables can be union elements in the generated language: " +
|
"only tables can be union elements in the generated language: " +
|
||||||
val.name);
|
val.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user