mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 20:04:13 +00:00
committed by
Wouter van Oortmerssen
parent
cef8f928bb
commit
90441c2078
@@ -670,11 +670,11 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
|
|||||||
|
|
||||||
if (token_ == '=') {
|
if (token_ == '=') {
|
||||||
NEXT();
|
NEXT();
|
||||||
|
ECHECK(ParseSingleValue(&field->name, field->value, true));
|
||||||
if (!IsScalar(type.base_type) ||
|
if (!IsScalar(type.base_type) ||
|
||||||
(struct_def.fixed && field->value.constant != "0"))
|
(struct_def.fixed && field->value.constant != "0"))
|
||||||
return Error(
|
return Error(
|
||||||
"default values currently only supported for scalars in tables");
|
"default values currently only supported for scalars in tables");
|
||||||
ECHECK(ParseSingleValue(&field->name, field->value, true));
|
|
||||||
}
|
}
|
||||||
if (type.enum_def &&
|
if (type.enum_def &&
|
||||||
!type.enum_def->is_union &&
|
!type.enum_def->is_union &&
|
||||||
|
|||||||
@@ -1275,6 +1275,7 @@ void ErrorTest() {
|
|||||||
TestError("table Y {} table X { Y:int; }", "same as table");
|
TestError("table Y {} table X { Y:int; }", "same as table");
|
||||||
TestError("struct X { Y:string; }", "only scalar");
|
TestError("struct X { Y:string; }", "only scalar");
|
||||||
TestError("table X { Y:string = \"\"; }", "default values");
|
TestError("table X { Y:string = \"\"; }", "default values");
|
||||||
|
TestError("struct X { a:uint = 42; }", "default values");
|
||||||
TestError("enum Y:byte { Z = 1 } table X { y:Y; }", "not part of enum");
|
TestError("enum Y:byte { Z = 1 } table X { y:Y; }", "not part of enum");
|
||||||
TestError("struct X { Y:int (deprecated); }", "deprecate");
|
TestError("struct X { Y:int (deprecated); }", "deprecate");
|
||||||
TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }",
|
TestError("union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }",
|
||||||
|
|||||||
Reference in New Issue
Block a user