Skip to content

Commit 9a31aa4

Browse files
committed
fix: prevent crash when using 'trap' keyword in specific contexts
1 parent e9e66b5 commit 9a31aa4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

argon/lang/parser2/parser2.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,8 @@ Node *Parser::ParseTrap(Context *context) {
27762776
this->Eat(true);
27772777

27782778
auto *right = this->ParseExpression(context, PeekPrecedence(TokenType::COMMA));
2779+
if (right == nullptr)
2780+
throw ParserException(this->tkcur_.loc, kStandardError[0]);
27792781

27802782
// Expressions with multiple traps are useless,
27812783
// if the expression is already a trap, return it immediately
@@ -2917,10 +2919,10 @@ Module *Parser::Parse() {
29172919
// This exception can be safely ignored!
29182920
return nullptr;
29192921
} catch (const ParserException &e) {
2920-
ErrorFormat("ParserError", "%s - column: %d, line: %d: %s",
2922+
ErrorFormat("ParserError", "%s - line: %d, column: %d: %s",
29212923
this->filename_,
2922-
e.loc.start.column,
29232924
e.loc.start.line,
2925+
e.loc.start.column,
29242926
e.what());
29252927
return nullptr;
29262928
} catch (const ScannerException &) {

0 commit comments

Comments
 (0)