Don't parse expression on different line from return keyword
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-19 16:21:21 +02:00
parent b76548da16
commit 6f7d319148
4 changed files with 24 additions and 2 deletions

View File

@@ -172,10 +172,13 @@ namespace Porygon::Binder {
} else {
currentReturnType = this->_currentFunction->GetReturnType();
}
if (expression == nullptr && currentReturnType != nullptr) {
if (expression == nullptr && (currentReturnType != nullptr && currentReturnType -> GetClass() != TypeClass::Nil)) {
this->_scriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidReturnType, statement->GetStartPosition(),
statement->GetLength());
return new BoundBadStatement();
} else if (expression == nullptr){
currentReturnType = make_shared<ScriptType>(TypeClass::Nil);
return new BoundReturnStatement(nullptr);
}
auto boundExpression = this->BindExpression(expression);
auto expresionType = boundExpression->GetType();