dherman / esprit

A JavaScript parser written in Rust

Home Page:https://esprit.surge.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assign should be split into two distinct types

RReverser opened this issue · comments

Assign is currently too overloaded. One case is simple assignment:

x = 1
[a,b,c] = arr

where LHS is Patt - identifier, property, object or array pattern are all allowed

and another case is binary-operation-based assignment:

x += 10

where only AssignTarget - simple LHS (identifier or property) is allowed.

I think it makes sense to split Assign into SimpleAssign(Patt<AssignTarget>, Box<Expr>) and BinaryAssign(Binop, Box<Expr>) (names are up to discussion).