observablehq / parser

The Observable parser.
ISC License
176 stars 27 forks source link

Fix const checks inside destructuring expressions #194

Closed mbostock closed 3 years ago

mbostock commented 3 years ago

Fixes #182.

The previous logic for ArrayPattern and ObjectPattern was two strict: every identifier inside these nodes was assumed to be an assignment, but in e.g. ({foo: value} = …) and ({foo: value = bar}) only value is being assigned to, not foo or bar. In the new logic, only an ArrayPattern’s elements and an ObjectPattern’s property values are directly tested for assignment; everything else is detected via AssignmentPattern through the outer walk.