Skip to content

Commit

Permalink
fix: prefix * as unary operator, not a type
Browse files Browse the repository at this point in the history
  • Loading branch information
saffage committed May 8, 2024
1 parent 8d2b153 commit 62a5b1b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions parser/parse_ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ func (p *Parser) parseUnaryExpr() ast.Node {
},
}

case token.Asterisk:
asterisk := p.consume()

return &ast.PrefixOp{
X: p.parseUnaryExpr(),
Opr: &ast.Operator{
Start: asterisk.Start,
End: asterisk.End,
Kind: ast.OperatorDeref,
},
}

case token.Amp:
loc := p.consume().Start

Expand Down Expand Up @@ -800,18 +812,6 @@ func (p *Parser) parseType() ast.Node {
},
}

case token.Asterisk:
asterisk := p.consume()

return &ast.PrefixOp{
X: p.parseType(),
Opr: &ast.Operator{
Start: asterisk.Start,
End: asterisk.End,
Kind: ast.OperatorDeref,
},
}

case token.LBracket:
brackets := p.parseBracketList(p.parseExpr)

Expand Down

0 comments on commit 62a5b1b

Please sign in to comment.