From 4b9123baffc7c83d5d39f311d72d8cfcdf80e7e1 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 24 Aug 2021 09:41:39 -0400 Subject: [PATCH] fix parser string=null (#6810) Co-authored-by: Casper Neo --- src/idl_parser.cpp | 3 +-- tests/test.cpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 720e80323..a6fad123a 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -812,8 +812,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) { "or in structs."); if (IsString(type) || IsVector(type)) { advanced_features_ |= reflection::DefaultVectorsAndStrings; - if (field->value.constant != "0" && field->value.constant != "null" && - !SupportsDefaultVectorsAndStrings()) { + if (field->value.constant != "0" && !SupportsDefaultVectorsAndStrings()) { return Error( "Default values for strings and vectors are not supported in one " "of the specified programming languages"); diff --git a/tests/test.cpp b/tests/test.cpp index 7ae8a2b1e..866ba38a9 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -3883,6 +3883,7 @@ void StringVectorDefaultsTest() { schemas.push_back("table Monster { mana: string = \"\"; }"); schemas.push_back("table Monster { mana: string = \"mystr\"; }"); 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: [uint] = [ ]; }"); schemas.push_back("table Monster { mana: [byte] = [\t\t\n]; }");