Skip to content

Commit

Permalink
fix: prevent parser crash on invalid colon prefix in expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed Jul 26, 2024
1 parent 9c1dde4 commit e9e66b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions argon/lang/parser2/parser2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,11 @@ Node *Parser::ParseFuncNameParam(Context *context, bool parse_pexpr) {

bool identifier = false;

if (parse_pexpr)
if (parse_pexpr) {
id = this->ParseExpression(context, PeekPrecedence(TokenType::COMMA));
else if (this->CheckIDExt()) {
if (!id)
throw ParserException(TKCUR_LOC, kStandardError[0]);
} else if (this->CheckIDExt()) {
id = Parser::ParseIdentifierSimple(&this->tkcur_);
identifier = true;

Expand Down Expand Up @@ -2637,7 +2639,7 @@ Node *Parser::ParsePrefix(Context *context) {
this->Eat(true);

auto *right = this->ParseExpression(context, PeekPrecedence(TokenType::ASTERISK));
if(right == nullptr)
if (right == nullptr)
throw ParserException(this->tkcur_.loc, kStandardError[0]);

auto *unary = NewNode<Unary>(type_ast_prefix_, false, NodeType::PREFIX);
Expand Down

0 comments on commit e9e66b5

Please sign in to comment.