diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index b852534..85d1823 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -148,13 +148,13 @@ namespace Porygon::Parser { } auto identifier = this->Next(); auto next = this->Next(); - if (type->GetKind() != TokenKind::Identifier && !hasErrors) { + if (!hasErrors && type->GetKind() != TokenKind::Identifier) { this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, type->GetStartPosition(), type->GetLength()); hasErrors = true; continue; } - if (identifier->GetKind() != TokenKind::Identifier && !hasErrors) { + if (!hasErrors && identifier->GetKind() != TokenKind::Identifier) { this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(), identifier->GetLength()); hasErrors = true; diff --git a/tests/integration/FunctionsTests.cpp b/tests/integration/FunctionsTests.cpp index 385da70..fc23bc3 100644 --- a/tests/integration/FunctionsTests.cpp +++ b/tests/integration/FunctionsTests.cpp @@ -189,5 +189,14 @@ stringResult = add('foo', 'bar') delete stringVar; } +TEST_CASE( "Malformed parameter logs error", "[integration]" ) { + Script* script = Script::Create(uR"( +function blockOwnCritical( move, target, hitNumber ) + return true +end +)"); + REQUIRE(script->Diagnostics -> HasErrors()); + delete script; +} #endif