Skip to content

Commit

Permalink
fix(parser): possible nil argument list
Browse files Browse the repository at this point in the history
  • Loading branch information
saffage committed Jun 18, 2024
1 parent 1b7046b commit 58bdbbd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions parser/parse_ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,23 @@ func (p *parser) parseSuffixExpr(x ast.Node) ast.Node {
x = p.parseDot(x)

case token.LBracket:
x = &ast.Index{
X: x,
Args: p.parseBracketList(p.parseExpr),
if args := p.parseBracketList(p.parseExpr); args != nil {
x = &ast.Index{
X: x,
Args: args,
}
} else {
return nil
}

case token.LParen:
x = &ast.Call{
X: x,
Args: p.parseParenList(p.declOr(p.parseExpr)),
if args := p.parseParenList(p.declOr(p.parseExpr)); args != nil {
x = &ast.Call{
X: x,
Args: args,
}
} else {
return nil
}

default:
Expand Down

0 comments on commit 58bdbbd

Please sign in to comment.