mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-05 23:36:53 +00:00
Disallow defaults on structs.
Change-Id: Ia098126c92ea6f8abe94561bd9c09b29ac8f61f5 Context: https://github.com/google/flatbuffers/issues/4591 Tested: on Linux.
This commit is contained in:
@@ -648,8 +648,9 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
|
|||||||
|
|
||||||
if (token_ == '=') {
|
if (token_ == '=') {
|
||||||
NEXT();
|
NEXT();
|
||||||
if (!IsScalar(type.base_type))
|
if (!IsScalar(type.base_type) || struct_def.fixed)
|
||||||
return Error("default values currently only supported for scalars");
|
return Error(
|
||||||
|
"default values currently only supported for scalars in tables");
|
||||||
ECHECK(ParseSingleValue(field->value));
|
ECHECK(ParseSingleValue(field->value));
|
||||||
}
|
}
|
||||||
if (IsFloat(field->value.type.base_type)) {
|
if (IsFloat(field->value.type.base_type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user