Skip to content

Commit 48328b9

Browse files
committed
fix: corrected a parser error that could cause Argon to crash
1 parent 8b490cd commit 48328b9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

argon/lang/parser2/parser2.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,8 @@ Node *Parser::ParseNullCoalescing(Context *context, Node *left) {
24982498
this->Eat(true);
24992499

25002500
auto *expr = this->ParseExpression(context, PeekPrecedence(TokenType::NULL_COALESCING));
2501+
if (expr == nullptr)
2502+
throw ParserException(this->tkcur_.loc, kStandardError[0]);
25012503

25022504
auto *n_coal = NewNode<Binary>(type_ast_binary_, false, NodeType::NULL_COALESCING);
25032505
if (n_coal == nullptr) {
@@ -2519,6 +2521,9 @@ Node *Parser::ParsePipeline(Context *context, Node *left) {
25192521
this->Eat(true);
25202522

25212523
auto *right = this->ParseExpression(context, PeekPrecedence(TokenType::PIPELINE));
2524+
if (right == nullptr)
2525+
throw ParserException(this->tkcur_.loc, kStandardError[0]);
2526+
25222527
if (right->node_type == NodeType::CALL) {
25232528
auto *call = (Call *) right;
25242529

@@ -2696,7 +2701,9 @@ Node *Parser::ParseTernary(Context *context, Node *left) {
26962701

26972702
this->Eat(true);
26982703

2699-
body = (ArObject *) this->ParseExpression(context, PeekPrecedence(TokenType::COMMA));
2704+
body = this->ParseExpression(context, PeekPrecedence(TokenType::COMMA));
2705+
if (!body)
2706+
throw ParserException(this->tkcur_.loc, kStandardError[0]);
27002707

27012708
this->IgnoreNewLineIF(TokenType::COLON);
27022709

0 commit comments

Comments
 (0)