Fixed return followed by end keyword log an error
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-09-14 10:45:32 +02:00
parent 12c55a12ba
commit e75d13f509
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 6 additions and 2 deletions

View File

@ -128,7 +128,7 @@ namespace Porygon::Parser {
return new ParsedBlockStatement(statements, start);
}
auto end = 0;
if (statements.size() > 0){
if (!statements.empty()){
end = statements.back()->GetEndPosition();
}
return new ParsedBlockStatement(statements, start, end - start);
@ -214,7 +214,11 @@ namespace Porygon::Parser {
if (startLine != this -> ScriptData -> Diagnostics -> GetLineFromPosition(this -> Peek() -> GetStartPosition())){
return new ParsedReturnStatement(nullptr, start, current->GetLength());
}
auto expression = this->ParseExpression(this->Next());
auto n = this->Peek()->GetKind();
ParsedExpression* expression = nullptr;
if (n != TokenKind::EndKeyword &&
n != TokenKind::EndOfFile)
expression = this->ParseExpression(this->Next());
return new ParsedReturnStatement(expression, start, expression->GetEndPosition() - start);
}