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

@@ -192,8 +192,12 @@ namespace Porygon::Parser {
ParsedStatement *Parser::ParseReturnStatement(const IToken *current) {
//TODO: if next token is on a different line, don't parse it as return expression.
auto expression = this->ParseExpression(this->Next());
auto start = current->GetStartPosition();
auto startLine = this -> ScriptData -> Diagnostics ->GetLineFromPosition(start);
if (startLine != this -> ScriptData -> Diagnostics -> GetLineFromPosition(this -> Peek() -> GetStartPosition())){
return new ParsedReturnStatement(nullptr, start, current->GetLength());
}
auto expression = this->ParseExpression(this->Next());
return new ParsedReturnStatement(expression, start, expression->GetEndPosition() - start);
}