Skip to content

Commit

Permalink
JS: support 'PrivateIdentifier in ShiftExpression'
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Oct 28, 2023
1 parent 9be4e68 commit 66f4235
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion js/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func (v Var) JS(w io.Writer) {
}

// VarsByUses is sortable by uses in descending order.
// TODO: write custom sorter for varsbyuses
type VarsByUses VarArray

func (vs VarsByUses) Len() int {
Expand Down
8 changes: 7 additions & 1 deletion js/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,13 @@ func (p *Parser) parseExpression(prec OpPrec) IExpr {
template := p.parseTemplateLiteral(precLeft)
left = &template
p.in = prevIn
// TODO: private identifier for relational operators
case PrivateIdentifierToken:
left = &LiteralExpr{p.tt, p.data}
p.next()
if p.tt != InToken {
p.fail("relational expression", InToken)
return left
}
default:
p.fail("expression")
return nil
Expand Down
1 change: 1 addition & 0 deletions js/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func TestParse(t *testing.T) {
{"protected = 0", "Stmt(protected=0)"},
{"public = 0", "Stmt(public=0)"},
{"static = 0", "Stmt(static=0)"},
{"#x in a", "Stmt(#x in a)"},

// expression to arrow function parameters
{"x = (a,b,c) => {a++}", "Stmt(x=(Params(Binding(a), Binding(b), Binding(c)) => Stmt({ Stmt(a++) })))"},
Expand Down

0 comments on commit 66f4235

Please sign in to comment.