Fixed flatc silently accepting non-scalars as default values.
Bug: 17304016 Change-Id: I4873f8ef32fbb2657f15fc53a2c8f767e10f2d96 Tested: on Linux
This commit is contained in:
parent
766d0df797
commit
15dc1a86cd
|
@ -364,6 +364,8 @@ void Parser::ParseField(StructDef &struct_def) {
|
|||
|
||||
if (token_ == '=') {
|
||||
Next();
|
||||
if (!IsScalar(type.base_type))
|
||||
Error("default values currently only supported for scalars");
|
||||
ParseSingleValue(field.value);
|
||||
}
|
||||
|
||||
|
|
|
@ -489,6 +489,7 @@ void ErrorTest() {
|
|||
TestError("union X { Y }", "referenced");
|
||||
TestError("union Z { X } struct X { Y:int; }", "only tables");
|
||||
TestError("table X { Y:[int]; YLength:int; }", "clash");
|
||||
TestError("table X { Y:string = 1; }", "scalar");
|
||||
}
|
||||
|
||||
// Additional parser testing not covered elsewhere.
|
||||
|
|
Loading…
Reference in New Issue