Summary
Introduced alongside #754 (assignment destructuring). A nested array/object pattern that itself carries a default in an assignment destructuring is rejected:
let a;
[[a] = []] = [[1]]; // Parse Error: Nested destructuring with a default is not supported in assignment destructuring.
({ p: { x } = {} } = { p: { x: 1 } });
Simpler forms all work: [[a], b] = [[1], 2] (nested, no default), [a = 5] = [] (leaf default), [obj.x = 5] = arr (member default).
Cause
[a] = [] inside the outer pattern is eagerly parsed by Assignment() as an Expr.DestructuringAssign (the inner is lowered to statements), so when the outer pattern walk in Parser.Destructuring.cs (LowerElementWithDefault) encounters it, the inner pattern's raw target/default are no longer recoverable. SharpTS has no cover grammar, so the inner cannot be reinterpreted as "nested pattern + default".
Fix shape
Either keep an un-lowered raw (target, value) on DestructuringAssign for re-interpretation when it appears as a nested element, or add a cover-grammar reparse for the LHS of =. The walk already handles every other element kind (leaf, member, leaf-default, member-default, nested-no-default, rest, holes).
Scope
Rare in practice. The current behavior is a clear parse error (not a miscompile).
Summary
Introduced alongside #754 (assignment destructuring). A nested array/object pattern that itself carries a default in an assignment destructuring is rejected:
Simpler forms all work:
[[a], b] = [[1], 2](nested, no default),[a = 5] = [](leaf default),[obj.x = 5] = arr(member default).Cause
[a] = []inside the outer pattern is eagerly parsed byAssignment()as anExpr.DestructuringAssign(the inner is lowered to statements), so when the outer pattern walk inParser.Destructuring.cs(LowerElementWithDefault) encounters it, the inner pattern's raw target/default are no longer recoverable. SharpTS has no cover grammar, so the inner cannot be reinterpreted as "nested pattern + default".Fix shape
Either keep an un-lowered raw
(target, value)onDestructuringAssignfor re-interpretation when it appears as a nested element, or add a cover-grammar reparse for the LHS of=. The walk already handles every other element kind (leaf, member, leaf-default, member-default, nested-no-default, rest, holes).Scope
Rare in practice. The current behavior is a clear parse error (not a miscompile).