Added exceptions for inconsistent use of typing.

This commit is contained in:
Patrick Lühne 2017-06-19 01:08:27 +02:00
parent 17b8306394
commit ce812d449b
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 10 additions and 0 deletions

View File

@ -56,6 +56,11 @@ void parseAndAddConstantDeclarations(Context &context, ast::Domain &domain, ast:
tokenizer.skipWhiteSpace(); tokenizer.skipWhiteSpace();
} }
const bool isTypingUsed = !domain.types.empty();
if (isTypingUsed && !constantDeclarations.empty() && !constantDeclarations.back()->type)
throw ParserException(tokenizer, "missing type declaration for constant “" + constantDeclarations.back()->name + "");
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -56,6 +56,11 @@ void parseAndAddVariableDeclarations(Context &context, ast::Domain &domain, ast:
tokenizer.skipWhiteSpace(); tokenizer.skipWhiteSpace();
} }
const bool isTypingUsed = !domain.types.empty();
if (isTypingUsed && !variableDeclarations.empty() && !variableDeclarations.back()->type)
throw ParserException(tokenizer, "missing type declaration for variable “?" + variableDeclarations.back()->name + "");
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////