Accepting new baselines

This commit is contained in:
Anders Hejlsberg
2016-04-16 15:13:48 -07:00
parent 9aea708953
commit 10889a042c
5 changed files with 383 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(11,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(22,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(34,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts(45,17): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/controlFlow/controlFlowIterationErrors.ts (4 errors) ====
let cond: boolean;
function len(s: string) {
return s.length;
}
function f1() {
let x: string | number | boolean;
x = "";
while (cond) {
x = len(x);
~
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
x;
}
x;
}
function f2() {
let x: string | number | boolean;
x = "";
while (cond) {
x;
x = len(x);
~
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'string'.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
}
x;
}
declare function foo(x: string): number;
declare function foo(x: number): string;
function g1() {
let x: string | number | boolean;
x = "";
while (cond) {
x = foo(x);
~
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
x;
}
x;
}
function g2() {
let x: string | number | boolean;
x = "";
while (cond) {
x;
x = foo(x);
~
!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
x;
}

View File

@@ -0,0 +1,92 @@
//// [controlFlowIterationErrors.ts]
let cond: boolean;
function len(s: string) {
return s.length;
}
function f1() {
let x: string | number | boolean;
x = "";
while (cond) {
x = len(x);
x;
}
x;
}
function f2() {
let x: string | number | boolean;
x = "";
while (cond) {
x;
x = len(x);
}
x;
}
declare function foo(x: string): number;
declare function foo(x: number): string;
function g1() {
let x: string | number | boolean;
x = "";
while (cond) {
x = foo(x);
x;
}
x;
}
function g2() {
let x: string | number | boolean;
x = "";
while (cond) {
x;
x = foo(x);
}
x;
}
//// [controlFlowIterationErrors.js]
var cond;
function len(s) {
return s.length;
}
function f1() {
var x;
x = "";
while (cond) {
x = len(x);
x;
}
x;
}
function f2() {
var x;
x = "";
while (cond) {
x;
x = len(x);
}
x;
}
function g1() {
var x;
x = "";
while (cond) {
x = foo(x);
x;
}
x;
}
function g2() {
var x;
x = "";
while (cond) {
x;
x = foo(x);
}
x;
}

View File

@@ -76,6 +76,35 @@ function g() {
}
x; // number
}
function h1() {
let x: string | number | boolean;
x = "";
while (x > 1) {
x; // string | number
x = 1;
x; // number
}
x; // string | number
}
declare function len(s: string | number): number;
function h2() {
let x: string | number | boolean;
x = "";
while (cond) {
x = len(x);
x; // number
}
x; // string | number
}
function h3() {
let x: string | number | boolean;
x = "";
while (cond) {
x; // string | number
x = len(x);
}
x; // string | number
}
//// [controlFlowWhileStatement.js]
@@ -157,3 +186,31 @@ function g() {
}
x; // number
}
function h1() {
var x;
x = "";
while (x > 1) {
x; // string | number
x = 1;
x; // number
}
x; // string | number
}
function h2() {
var x;
x = "";
while (cond) {
x = len(x);
x; // number
}
x; // string | number
}
function h3() {
var x;
x = "";
while (cond) {
x; // string | number
x = len(x);
}
x; // string | number
}

View File

@@ -180,4 +180,78 @@ function g() {
x; // number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 62, 7))
}
function h1() {
>h1 : Symbol(h1, Decl(controlFlowWhileStatement.ts, 76, 1))
let x: string | number | boolean;
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
x = "";
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
while (x > 1) {
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
x; // string | number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
x = 1;
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
x; // number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
}
x; // string | number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 78, 7))
}
declare function len(s: string | number): number;
>len : Symbol(len, Decl(controlFlowWhileStatement.ts, 86, 1))
>s : Symbol(s, Decl(controlFlowWhileStatement.ts, 87, 21))
function h2() {
>h2 : Symbol(h2, Decl(controlFlowWhileStatement.ts, 87, 49))
let x: string | number | boolean;
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
x = "";
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
while (cond) {
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
x = len(x);
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
>len : Symbol(len, Decl(controlFlowWhileStatement.ts, 86, 1))
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
x; // number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
}
x; // string | number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 89, 7))
}
function h3() {
>h3 : Symbol(h3, Decl(controlFlowWhileStatement.ts, 96, 1))
let x: string | number | boolean;
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
x = "";
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
while (cond) {
>cond : Symbol(cond, Decl(controlFlowWhileStatement.ts, 0, 3))
x; // string | number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
x = len(x);
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
>len : Symbol(len, Decl(controlFlowWhileStatement.ts, 86, 1))
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
}
x; // string | number
>x : Symbol(x, Decl(controlFlowWhileStatement.ts, 98, 7))
}

View File

@@ -219,4 +219,92 @@ function g() {
x; // number
>x : number
}
function h1() {
>h1 : () => void
let x: string | number | boolean;
>x : string | number | boolean
x = "";
>x = "" : string
>x : string | number | boolean
>"" : string
while (x > 1) {
>x > 1 : boolean
>x : string | number
>1 : number
x; // string | number
>x : string | number
x = 1;
>x = 1 : number
>x : string | number | boolean
>1 : number
x; // number
>x : number
}
x; // string | number
>x : string | number
}
declare function len(s: string | number): number;
>len : (s: string | number) => number
>s : string | number
function h2() {
>h2 : () => void
let x: string | number | boolean;
>x : string | number | boolean
x = "";
>x = "" : string
>x : string | number | boolean
>"" : string
while (cond) {
>cond : boolean
x = len(x);
>x = len(x) : number
>x : string | number | boolean
>len(x) : number
>len : (s: string | number) => number
>x : string | number
x; // number
>x : number
}
x; // string | number
>x : string | number
}
function h3() {
>h3 : () => void
let x: string | number | boolean;
>x : string | number | boolean
x = "";
>x = "" : string
>x : string | number | boolean
>"" : string
while (cond) {
>cond : boolean
x; // string | number
>x : string | number
x = len(x);
>x = len(x) : number
>x : string | number | boolean
>len(x) : number
>len : (s: string | number) => number
>x : string | number
}
x; // string | number
>x : string | number
}