mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Fixing repro test
This commit is contained in:
39
tests/baselines/reference/controlFlowLoopAnalysis.errors.txt
Normal file
39
tests/baselines/reference/controlFlowLoopAnalysis.errors.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
tests/cases/compiler/controlFlowLoopAnalysis.ts(13,25): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
|
||||
Type 'undefined' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowLoopAnalysis.ts (1 errors) ====
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
let cond: boolean;
|
||||
|
||||
function foo(x: number): number { return 1; }
|
||||
|
||||
function test1() {
|
||||
let x: number | undefined;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
|
||||
!!! error TS2345: Type 'undefined' is not assignable to type 'number'.
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
function test2() {
|
||||
let x: number | undefined;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
58
tests/baselines/reference/controlFlowLoopAnalysis.js
Normal file
58
tests/baselines/reference/controlFlowLoopAnalysis.js
Normal file
@@ -0,0 +1,58 @@
|
||||
//// [controlFlowLoopAnalysis.ts]
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
let cond: boolean;
|
||||
|
||||
function foo(x: number): number { return 1; }
|
||||
|
||||
function test1() {
|
||||
let x: number | undefined;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
function test2() {
|
||||
let x: number | undefined;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowLoopAnalysis.js]
|
||||
// Repro from #8418
|
||||
var cond;
|
||||
function foo(x) { return 1; }
|
||||
function test1() {
|
||||
var x;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
// Repro from #8418
|
||||
function test2() {
|
||||
var x;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,29 +105,6 @@ function h3() {
|
||||
}
|
||||
x; // string | number
|
||||
}
|
||||
// Repro for #8418
|
||||
function foo(x: number): number { return 1; }
|
||||
function test1() {
|
||||
let x: number | undefined;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
// Repro for #8418
|
||||
function test2() {
|
||||
let x: number | undefined;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowWhileStatement.js]
|
||||
@@ -237,26 +214,3 @@ function h3() {
|
||||
}
|
||||
x; // string | number
|
||||
}
|
||||
// Repro for #8418
|
||||
function foo(x) { return 1; }
|
||||
function test1() {
|
||||
var x;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
// Repro for #8418
|
||||
function test2() {
|
||||
var x;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,57 +254,4 @@ function h3() {
|
||||
x; // string | number
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
|
||||
}
|
||||
// Repro for #8418
|
||||
function foo(x: number): number { return 1; }
|
||||
>foo : Symbol(foo, Decl(controlFlowWhileStatement.ts, 105, 1))
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 107, 13))
|
||||
|
||||
function test1() {
|
||||
>test1 : Symbol(test1, Decl(controlFlowWhileStatement.ts, 107, 45))
|
||||
|
||||
let x: number | undefined;
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 109, 7))
|
||||
|
||||
while (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
|
||||
|
||||
while (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
|
||||
|
||||
while (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
|
||||
|
||||
x = foo(x);
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 109, 7))
|
||||
>foo : Symbol(foo, Decl(controlFlowWhileStatement.ts, 105, 1))
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 109, 7))
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 109, 7))
|
||||
}
|
||||
}
|
||||
// Repro for #8418
|
||||
function test2() {
|
||||
>test2 : Symbol(test2, Decl(controlFlowWhileStatement.ts, 118, 1))
|
||||
|
||||
let x: number | undefined;
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 121, 7))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 121, 7))
|
||||
|
||||
while (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
|
||||
|
||||
while (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
|
||||
|
||||
x = foo(x);
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 121, 7))
|
||||
>foo : Symbol(foo, Decl(controlFlowWhileStatement.ts, 105, 1))
|
||||
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 121, 7))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,66 +307,4 @@ function h3() {
|
||||
x; // string | number
|
||||
>x : string | number
|
||||
}
|
||||
// Repro for #8418
|
||||
function foo(x: number): number { return 1; }
|
||||
>foo : (x: number) => number
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
function test1() {
|
||||
>test1 : () => void
|
||||
|
||||
let x: number | undefined;
|
||||
>x : number
|
||||
|
||||
while (cond) {
|
||||
>cond : boolean
|
||||
|
||||
while (cond) {
|
||||
>cond : boolean
|
||||
|
||||
while (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = foo(x);
|
||||
>x = foo(x) : number
|
||||
>x : number
|
||||
>foo(x) : number
|
||||
>foo : (x: number) => number
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
>x = 1 : number
|
||||
>x : number
|
||||
>1 : number
|
||||
}
|
||||
}
|
||||
// Repro for #8418
|
||||
function test2() {
|
||||
>test2 : () => void
|
||||
|
||||
let x: number | undefined;
|
||||
>x : number
|
||||
|
||||
x = 1;
|
||||
>x = 1 : number
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
while (cond) {
|
||||
>cond : boolean
|
||||
|
||||
while (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = foo(x);
|
||||
>x = foo(x) : number
|
||||
>x : number
|
||||
>foo(x) : number
|
||||
>foo : (x: number) => number
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
31
tests/cases/compiler/controlFlowLoopAnalysis.ts
Normal file
31
tests/cases/compiler/controlFlowLoopAnalysis.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
let cond: boolean;
|
||||
|
||||
function foo(x: number): number { return 1; }
|
||||
|
||||
function test1() {
|
||||
let x: number | undefined;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #8418
|
||||
|
||||
function test2() {
|
||||
let x: number | undefined;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,26 +104,3 @@ function h3() {
|
||||
}
|
||||
x; // string | number
|
||||
}
|
||||
// Repro for #8418
|
||||
function foo(x: number): number { return 1; }
|
||||
function test1() {
|
||||
let x: number | undefined;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
// Repro for #8418
|
||||
function test2() {
|
||||
let x: number | undefined;
|
||||
x = 1;
|
||||
while (cond) {
|
||||
while (cond) {
|
||||
x = foo(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user