mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +02:00
The Rust parser used to copy several "rule_start"-derived positions
from the C++ implementation: every identifier inside a binding pattern
inherited the pattern's `[`/`{` position, every property identifier
after `.` inherited the period's position, every spread element
inherited the surrounding `[`/`{` position, and identifier-name
property keys inherited the object/class start position. This was
useful while comparing bytecode against the C++ port; with the C++
side gone, those quirks just hide the actual source positions in
source maps and devtools.
Drop the dedicated `binding_pattern_start` parser field and the
`ident_pos_override` parameter on `parse_property_key`, and capture
each identifier's own start position at the consume site.
Add an AST snapshot test that pins the new per-identifier positions
for object, array, nested, and parameter binding patterns.
15 lines
474 B
JavaScript
15 lines
474 B
JavaScript
// Identifiers inside a binding pattern should carry their own start
|
|
// position. Previously they inherited the pattern's opening `[` or `{`
|
|
// position, which made source maps and devtools point at the bracket
|
|
// rather than the binding name.
|
|
|
|
let { foo, bar } = {};
|
|
let { x: aliased, y: also } = {};
|
|
let [ first, , third ] = [];
|
|
let { nested: { inner }, ...rest } = {};
|
|
let [ a, [ b, c ] ] = [];
|
|
|
|
function destructured({ p, q: r }, [ s, t ]) {
|
|
return p + r + s + t;
|
|
}
|