Allowing not declaring implicit “object” type without warning or error.

This commit is contained in:
Patrick Lühne 2017-06-18 22:58:14 +02:00
parent 4c0583c91f
commit bbf2a7d02d
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -33,10 +33,14 @@ ast::PrimitiveTypePointer parsePrimitiveType(Context &context, ast::Domain &doma
// If the type has not been declared yet, add it but issue a warning
if (matchingType == types.end())
{
if (context.mode != Mode::Compatibility)
throw ParserException(tokenizer, "primitive type “" + typeName + "” used without or before declaration");
// “object” type is always allowed without warning
if (typeName != "object")
{
if (context.mode != Mode::Compatibility)
throw ParserException(tokenizer, "primitive type “" + typeName + "” used without or before declaration");
context.warningCallback(tokenizer, "primitive type “" + typeName + "” used without or before declaration, silently adding declaration");
context.warningCallback(tokenizer, "primitive type “" + typeName + "” used without or before declaration, silently adding declaration");
}
types.emplace_back(std::make_unique<ast::PrimitiveTypeDeclaration>(std::move(typeName)));