fix parser string=null (#6810)
Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
parent
f89e0b1a6c
commit
4b9123baff
|
@ -812,8 +812,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
|
||||||
"or in structs.");
|
"or in structs.");
|
||||||
if (IsString(type) || IsVector(type)) {
|
if (IsString(type) || IsVector(type)) {
|
||||||
advanced_features_ |= reflection::DefaultVectorsAndStrings;
|
advanced_features_ |= reflection::DefaultVectorsAndStrings;
|
||||||
if (field->value.constant != "0" && field->value.constant != "null" &&
|
if (field->value.constant != "0" && !SupportsDefaultVectorsAndStrings()) {
|
||||||
!SupportsDefaultVectorsAndStrings()) {
|
|
||||||
return Error(
|
return Error(
|
||||||
"Default values for strings and vectors are not supported in one "
|
"Default values for strings and vectors are not supported in one "
|
||||||
"of the specified programming languages");
|
"of the specified programming languages");
|
||||||
|
|
|
@ -3883,6 +3883,7 @@ void StringVectorDefaultsTest() {
|
||||||
schemas.push_back("table Monster { mana: string = \"\"; }");
|
schemas.push_back("table Monster { mana: string = \"\"; }");
|
||||||
schemas.push_back("table Monster { mana: string = \"mystr\"; }");
|
schemas.push_back("table Monster { mana: string = \"mystr\"; }");
|
||||||
schemas.push_back("table Monster { mana: string = \" \"; }");
|
schemas.push_back("table Monster { mana: string = \" \"; }");
|
||||||
|
schemas.push_back("table Monster { mana: string = \"null\"; }");
|
||||||
schemas.push_back("table Monster { mana: [int] = []; }");
|
schemas.push_back("table Monster { mana: [int] = []; }");
|
||||||
schemas.push_back("table Monster { mana: [uint] = [ ]; }");
|
schemas.push_back("table Monster { mana: [uint] = [ ]; }");
|
||||||
schemas.push_back("table Monster { mana: [byte] = [\t\t\n]; }");
|
schemas.push_back("table Monster { mana: [byte] = [\t\t\n]; }");
|
||||||
|
|
Loading…
Reference in New Issue