-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix top level logical assignment leak (#40536)
* Fix leaking top level logical assignment * Fix leaking top level logical assignment
- Loading branch information
Showing
11 changed files
with
270 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/logicalAssignment11(target=es2015).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [logicalAssignment11.ts] | ||
let x: string | undefined; | ||
|
||
let d: string | undefined; | ||
d ?? (d = x ?? "x") | ||
d.length; | ||
|
||
let e: string | undefined; | ||
e ??= x ?? "x" | ||
e.length | ||
|
||
//// [logicalAssignment11.js] | ||
"use strict"; | ||
let x; | ||
let d; | ||
d !== null && d !== void 0 ? d : (d = x !== null && x !== void 0 ? x : "x"); | ||
d.length; | ||
let e; | ||
e !== null && e !== void 0 ? e : (e = x !== null && x !== void 0 ? x : "x"); | ||
e.length; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/logicalAssignment11(target=es2015).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
let d: string | undefined; | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
|
||
d ?? (d = x ?? "x") | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
d.length; | ||
>d.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
||
let e: string | undefined; | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
|
||
e ??= x ?? "x" | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
e.length | ||
>e.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/logicalAssignment11(target=es2015).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : string | undefined | ||
|
||
let d: string | undefined; | ||
>d : string | undefined | ||
|
||
d ?? (d = x ?? "x") | ||
>d ?? (d = x ?? "x") : string | ||
>d : string | undefined | ||
>(d = x ?? "x") : string | ||
>d = x ?? "x" : string | ||
>d : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
d.length; | ||
>d.length : number | ||
>d : string | ||
>length : number | ||
|
||
let e: string | undefined; | ||
>e : string | undefined | ||
|
||
e ??= x ?? "x" | ||
>e ??= x ?? "x" : string | ||
>e : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
e.length | ||
>e.length : number | ||
>e : string | ||
>length : number | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/logicalAssignment11(target=es2020).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [logicalAssignment11.ts] | ||
let x: string | undefined; | ||
|
||
let d: string | undefined; | ||
d ?? (d = x ?? "x") | ||
d.length; | ||
|
||
let e: string | undefined; | ||
e ??= x ?? "x" | ||
e.length | ||
|
||
//// [logicalAssignment11.js] | ||
"use strict"; | ||
let x; | ||
let d; | ||
d ?? (d = x ?? "x"); | ||
d.length; | ||
let e; | ||
e ?? (e = x ?? "x"); | ||
e.length; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/logicalAssignment11(target=es2020).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
let d: string | undefined; | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
|
||
d ?? (d = x ?? "x") | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
d.length; | ||
>d.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
||
let e: string | undefined; | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
|
||
e ??= x ?? "x" | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
e.length | ||
>e.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/logicalAssignment11(target=es2020).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : string | undefined | ||
|
||
let d: string | undefined; | ||
>d : string | undefined | ||
|
||
d ?? (d = x ?? "x") | ||
>d ?? (d = x ?? "x") : string | ||
>d : string | undefined | ||
>(d = x ?? "x") : string | ||
>d = x ?? "x" : string | ||
>d : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
d.length; | ||
>d.length : number | ||
>d : string | ||
>length : number | ||
|
||
let e: string | undefined; | ||
>e : string | undefined | ||
|
||
e ??= x ?? "x" | ||
>e ??= x ?? "x" : string | ||
>e : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
e.length | ||
>e.length : number | ||
>e : string | ||
>length : number | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/logicalAssignment11(target=esnext).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [logicalAssignment11.ts] | ||
let x: string | undefined; | ||
|
||
let d: string | undefined; | ||
d ?? (d = x ?? "x") | ||
d.length; | ||
|
||
let e: string | undefined; | ||
e ??= x ?? "x" | ||
e.length | ||
|
||
//// [logicalAssignment11.js] | ||
"use strict"; | ||
let x; | ||
let d; | ||
d ?? (d = x ?? "x"); | ||
d.length; | ||
let e; | ||
e ??= x ?? "x"; | ||
e.length; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/logicalAssignment11(target=esnext).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
let d: string | undefined; | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
|
||
d ?? (d = x ?? "x") | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
d.length; | ||
>d.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>d : Symbol(d, Decl(logicalAssignment11.ts, 2, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
||
let e: string | undefined; | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
|
||
e ??= x ?? "x" | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>x : Symbol(x, Decl(logicalAssignment11.ts, 0, 3)) | ||
|
||
e.length | ||
>e.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>e : Symbol(e, Decl(logicalAssignment11.ts, 6, 3)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/logicalAssignment11(target=esnext).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts === | ||
let x: string | undefined; | ||
>x : string | undefined | ||
|
||
let d: string | undefined; | ||
>d : string | undefined | ||
|
||
d ?? (d = x ?? "x") | ||
>d ?? (d = x ?? "x") : string | ||
>d : string | undefined | ||
>(d = x ?? "x") : string | ||
>d = x ?? "x" : string | ||
>d : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
d.length; | ||
>d.length : number | ||
>d : string | ||
>length : number | ||
|
||
let e: string | undefined; | ||
>e : string | undefined | ||
|
||
e ??= x ?? "x" | ||
>e ??= x ?? "x" : string | ||
>e : string | undefined | ||
>x ?? "x" : string | ||
>x : string | undefined | ||
>"x" : "x" | ||
|
||
e.length | ||
>e.length : number | ||
>e : string | ||
>length : number | ||
|
12 changes: 12 additions & 0 deletions
12
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment11.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @strict: true | ||
// @target: esnext, es2020, es2015 | ||
|
||
let x: string | undefined; | ||
|
||
let d: string | undefined; | ||
d ?? (d = x ?? "x") | ||
d.length; | ||
|
||
let e: string | undefined; | ||
e ??= x ?? "x" | ||
e.length |