Fixed flatc silently accepting non-scalars as default values.

Bug: 17304016
Change-Id: I4873f8ef32fbb2657f15fc53a2c8f767e10f2d96
Tested: on Linux
parent 766d0df7
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment