From 0392f4f55fe81efca0dd77c672c2f94c9d97b8df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:34:12 +0000 Subject: [PATCH] Add additional destructuring recursion tests Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...gContextualBindingStackOverflow.errors.txt | 34 +++++++++++++- ...ructuringContextualBindingStackOverflow.js | 4 ++ ...ringContextualBindingStackOverflow.symbols | 15 +++++++ ...turingContextualBindingStackOverflow.types | 44 +++++++++++++++++++ ...ructuringContextualBindingStackOverflow.ts | 2 + 5 files changed, 98 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/destructuringContextualBindingStackOverflow.errors.txt b/tests/baselines/reference/destructuringContextualBindingStackOverflow.errors.txt index be4d1692381..ca54c0d2c73 100644 --- a/tests/baselines/reference/destructuringContextualBindingStackOverflow.errors.txt +++ b/tests/baselines/reference/destructuringContextualBindingStackOverflow.errors.txt @@ -2,9 +2,18 @@ destructuringContextualBindingStackOverflow.ts(1,7): error TS2322: Type '{ c: nu destructuringContextualBindingStackOverflow.ts(1,9): error TS2339: Property 'c' does not exist on type 'string | number | symbol'. destructuringContextualBindingStackOverflow.ts(1,12): error TS2339: Property 'f' does not exist on type 'string | number | symbol'. destructuringContextualBindingStackOverflow.ts(1,52): error TS2448: Block-scoped variable 'f' used before its declaration. +destructuringContextualBindingStackOverflow.ts(2,7): error TS2322: Type '{ a: number; f: any; }' is not assignable to type 'string | number'. +destructuringContextualBindingStackOverflow.ts(2,9): error TS2339: Property 'a' does not exist on type 'string | number'. +destructuringContextualBindingStackOverflow.ts(2,12): error TS2339: Property 'f' does not exist on type 'string | number'. +destructuringContextualBindingStackOverflow.ts(2,55): error TS2448: Block-scoped variable 'f1' used before its declaration. +destructuringContextualBindingStackOverflow.ts(3,7): error TS2322: Type '{ a: any; f: any; }' is not assignable to type 'string | number'. +destructuringContextualBindingStackOverflow.ts(3,9): error TS2339: Property 'a' does not exist on type 'string | number'. +destructuringContextualBindingStackOverflow.ts(3,16): error TS2339: Property 'f' does not exist on type 'string | number'. +destructuringContextualBindingStackOverflow.ts(3,48): error TS2448: Block-scoped variable 'f2' used before its declaration. +destructuringContextualBindingStackOverflow.ts(3,55): error TS2448: Block-scoped variable 'a1' used before its declaration. -==== destructuringContextualBindingStackOverflow.ts (4 errors) ==== +==== destructuringContextualBindingStackOverflow.ts (13 errors) ==== const { c, f }: string | number | symbol = { c: 0, f }; ~~~~~~~~ !!! error TS2322: Type '{ c: number; f: any; }' is not assignable to type 'string | number | symbol'. @@ -15,4 +24,27 @@ destructuringContextualBindingStackOverflow.ts(1,52): error TS2448: Block-scoped ~ !!! error TS2448: Block-scoped variable 'f' used before its declaration. !!! related TS2728 destructuringContextualBindingStackOverflow.ts:1:12: 'f' is declared here. + const { a, f: f1 }: string | number = { a: 0, f: (1 + f1) }; + ~~~~~~~~~~~~ +!!! error TS2322: Type '{ a: number; f: any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'a' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~~ +!!! error TS2448: Block-scoped variable 'f1' used before its declaration. +!!! related TS2728 destructuringContextualBindingStackOverflow.ts:2:15: 'f1' is declared here. + const { a: a1, f: f2 }: string | number = { a: f2, f: a1 }; + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ a: any; f: any; }' is not assignable to type 'string | number'. + ~ +!!! error TS2339: Property 'a' does not exist on type 'string | number'. + ~ +!!! error TS2339: Property 'f' does not exist on type 'string | number'. + ~~ +!!! error TS2448: Block-scoped variable 'f2' used before its declaration. +!!! related TS2728 destructuringContextualBindingStackOverflow.ts:3:19: 'f2' is declared here. + ~~ +!!! error TS2448: Block-scoped variable 'a1' used before its declaration. +!!! related TS2728 destructuringContextualBindingStackOverflow.ts:3:12: 'a1' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringContextualBindingStackOverflow.js b/tests/baselines/reference/destructuringContextualBindingStackOverflow.js index 9d1de147d23..9e03fadbbd5 100644 --- a/tests/baselines/reference/destructuringContextualBindingStackOverflow.js +++ b/tests/baselines/reference/destructuringContextualBindingStackOverflow.js @@ -2,8 +2,12 @@ //// [destructuringContextualBindingStackOverflow.ts] const { c, f }: string | number | symbol = { c: 0, f }; +const { a, f: f1 }: string | number = { a: 0, f: (1 + f1) }; +const { a: a1, f: f2 }: string | number = { a: f2, f: a1 }; //// [destructuringContextualBindingStackOverflow.js] "use strict"; var _a = { c: 0, f: f }, c = _a.c, f = _a.f; +var _b = { a: 0, f: (1 + f1) }, a = _b.a, f1 = _b.f; +var _c = { a: f2, f: a1 }, a1 = _c.a, f2 = _c.f; diff --git a/tests/baselines/reference/destructuringContextualBindingStackOverflow.symbols b/tests/baselines/reference/destructuringContextualBindingStackOverflow.symbols index 1d8fc2524a4..45852adeb76 100644 --- a/tests/baselines/reference/destructuringContextualBindingStackOverflow.symbols +++ b/tests/baselines/reference/destructuringContextualBindingStackOverflow.symbols @@ -7,3 +7,18 @@ const { c, f }: string | number | symbol = { c: 0, f }; >c : Symbol(c, Decl(destructuringContextualBindingStackOverflow.ts, 0, 44)) >f : Symbol(f, Decl(destructuringContextualBindingStackOverflow.ts, 0, 50)) +const { a, f: f1 }: string | number = { a: 0, f: (1 + f1) }; +>a : Symbol(a, Decl(destructuringContextualBindingStackOverflow.ts, 1, 7)) +>f1 : Symbol(f1, Decl(destructuringContextualBindingStackOverflow.ts, 1, 10)) +>a : Symbol(a, Decl(destructuringContextualBindingStackOverflow.ts, 1, 39)) +>f : Symbol(f, Decl(destructuringContextualBindingStackOverflow.ts, 1, 45)) +>f1 : Symbol(f1, Decl(destructuringContextualBindingStackOverflow.ts, 1, 10)) + +const { a: a1, f: f2 }: string | number = { a: f2, f: a1 }; +>a1 : Symbol(a1, Decl(destructuringContextualBindingStackOverflow.ts, 2, 7)) +>f2 : Symbol(f2, Decl(destructuringContextualBindingStackOverflow.ts, 2, 14)) +>a : Symbol(a, Decl(destructuringContextualBindingStackOverflow.ts, 2, 43)) +>f2 : Symbol(f2, Decl(destructuringContextualBindingStackOverflow.ts, 2, 14)) +>f : Symbol(f, Decl(destructuringContextualBindingStackOverflow.ts, 2, 50)) +>a1 : Symbol(a1, Decl(destructuringContextualBindingStackOverflow.ts, 2, 7)) + diff --git a/tests/baselines/reference/destructuringContextualBindingStackOverflow.types b/tests/baselines/reference/destructuringContextualBindingStackOverflow.types index a1d79026336..d2552446243 100644 --- a/tests/baselines/reference/destructuringContextualBindingStackOverflow.types +++ b/tests/baselines/reference/destructuringContextualBindingStackOverflow.types @@ -15,3 +15,47 @@ const { c, f }: string | number | symbol = { c: 0, f }; >f : any > : ^^^ +const { a, f: f1 }: string | number = { a: 0, f: (1 + f1) }; +>a : any +> : ^^^ +>f : any +> : ^^^ +>f1 : any +> : ^^^ +>{ a: 0, f: (1 + f1) } : { a: number; f: any; } +> : ^^^^^^^^^^^^^^^^^^^^^^ +>a : number +> : ^^^^^^ +>0 : 0 +> : ^ +>f : any +> : ^^^ +>(1 + f1) : any +> : ^^^ +>1 + f1 : any +> : ^^^ +>1 : 1 +> : ^ +>f1 : any +> : ^^^ + +const { a: a1, f: f2 }: string | number = { a: f2, f: a1 }; +>a : any +> : ^^^ +>a1 : any +> : ^^^ +>f : any +> : ^^^ +>f2 : any +> : ^^^ +>{ a: f2, f: a1 } : { a: any; f: any; } +> : ^^^^^^^^^^^^^^^^^^^ +>a : any +> : ^^^ +>f2 : any +> : ^^^ +>f : any +> : ^^^ +>a1 : any +> : ^^^ + diff --git a/tests/cases/compiler/destructuringContextualBindingStackOverflow.ts b/tests/cases/compiler/destructuringContextualBindingStackOverflow.ts index 986d2fde213..6aa9592848d 100644 --- a/tests/cases/compiler/destructuringContextualBindingStackOverflow.ts +++ b/tests/cases/compiler/destructuringContextualBindingStackOverflow.ts @@ -1,3 +1,5 @@ // @strict: true const { c, f }: string | number | symbol = { c: 0, f }; +const { a, f: f1 }: string | number = { a: 0, f: (1 + f1) }; +const { a: a1, f: f2 }: string | number = { a: f2, f: a1 };