-
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.
Add try priors as finally lock label andecedents rather than pre fina…
- Loading branch information
Showing
5 changed files
with
138 additions
and
2 deletions.
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
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/controlFlowFinallyNoCatchAssignments.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,33 @@ | ||
//// [controlFlowFinallyNoCatchAssignments.ts] | ||
let x: number; | ||
x = Math.random(); | ||
let a: number; | ||
try { | ||
if (x) { | ||
a = 1; | ||
} else { | ||
a = 2; | ||
} | ||
} finally { | ||
console.log(x); | ||
} | ||
|
||
console.log(a); // <- error here | ||
|
||
//// [controlFlowFinallyNoCatchAssignments.js] | ||
"use strict"; | ||
var x; | ||
x = Math.random(); | ||
var a; | ||
try { | ||
if (x) { | ||
a = 1; | ||
} | ||
else { | ||
a = 2; | ||
} | ||
} | ||
finally { | ||
console.log(x); | ||
} | ||
console.log(a); // <- error here |
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/controlFlowFinallyNoCatchAssignments.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,38 @@ | ||
=== tests/cases/compiler/controlFlowFinallyNoCatchAssignments.ts === | ||
let x: number; | ||
>x : Symbol(x, Decl(controlFlowFinallyNoCatchAssignments.ts, 0, 3)) | ||
|
||
x = Math.random(); | ||
>x : Symbol(x, Decl(controlFlowFinallyNoCatchAssignments.ts, 0, 3)) | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
let a: number; | ||
>a : Symbol(a, Decl(controlFlowFinallyNoCatchAssignments.ts, 2, 3)) | ||
|
||
try { | ||
if (x) { | ||
>x : Symbol(x, Decl(controlFlowFinallyNoCatchAssignments.ts, 0, 3)) | ||
|
||
a = 1; | ||
>a : Symbol(a, Decl(controlFlowFinallyNoCatchAssignments.ts, 2, 3)) | ||
|
||
} else { | ||
a = 2; | ||
>a : Symbol(a, Decl(controlFlowFinallyNoCatchAssignments.ts, 2, 3)) | ||
} | ||
} finally { | ||
console.log(x); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(controlFlowFinallyNoCatchAssignments.ts, 0, 3)) | ||
} | ||
|
||
console.log(a); // <- error here | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>a : Symbol(a, Decl(controlFlowFinallyNoCatchAssignments.ts, 2, 3)) | ||
|
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/controlFlowFinallyNoCatchAssignments.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,46 @@ | ||
=== tests/cases/compiler/controlFlowFinallyNoCatchAssignments.ts === | ||
let x: number; | ||
>x : number | ||
|
||
x = Math.random(); | ||
>x = Math.random() : number | ||
>x : number | ||
>Math.random() : number | ||
>Math.random : () => number | ||
>Math : Math | ||
>random : () => number | ||
|
||
let a: number; | ||
>a : number | ||
|
||
try { | ||
if (x) { | ||
>x : number | ||
|
||
a = 1; | ||
>a = 1 : 1 | ||
>a : number | ||
>1 : 1 | ||
|
||
} else { | ||
a = 2; | ||
>a = 2 : 2 | ||
>a : number | ||
>2 : 2 | ||
} | ||
} finally { | ||
console.log(x); | ||
>console.log(x) : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>x : number | ||
} | ||
|
||
console.log(a); // <- error here | ||
>console.log(a) : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>a : number | ||
|
15 changes: 15 additions & 0 deletions
15
tests/cases/compiler/controlFlowFinallyNoCatchAssignments.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,15 @@ | ||
// @strict: true | ||
let x: number; | ||
x = Math.random(); | ||
let a: number; | ||
try { | ||
if (x) { | ||
a = 1; | ||
} else { | ||
a = 2; | ||
} | ||
} finally { | ||
console.log(x); | ||
} | ||
|
||
console.log(a); // <- error here |