Commit a20c55be authored by Vladimir Glavnyy's avatar Vladimir Glavnyy Committed by Wouter van Oortmerssen

Extend the error message if base type of parsed scalar not resolved (#5456)

* Extend the error message if base type of parsed scalar not resolved #5447

* Resolve PR notes
parent d7c2b388
......@@ -1639,6 +1639,7 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
// An integer constant in string.
TRY_ECHECK(kTokenStringOrIdent, IsInteger(in_type), BASE_TYPE_INT);
// Unknown tokens will be interpreted as string type.
// An attribute value may be a scalar or string constant.
FORCE_ECHECK(kTokenStringConstant, in_type == BASE_TYPE_STRING,
BASE_TYPE_STRING);
} else {
......@@ -1651,7 +1652,12 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
#undef TRY_ECHECK
#undef IF_ECHECK_
if (!match) return TokenError();
if (!match) {
std::string msg;
msg += "Cannot assign token starting with '" + TokenToStringId(token_) +
"' to value of <" + std::string(kTypeNames[in_type]) + "> type.";
return Error(msg);
}
const auto match_type = e.type.base_type; // may differ from in_type
// The check_now flag must be true when parse a fbs-schema.
// This flag forces to check default scalar values or metadata of field.
......
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