diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt new file mode 100644 index 0000000000..3efa85d1cc --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(3,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(8,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(10,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(12,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts (6 errors) ==== + function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // duplicate function + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + foo(); + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js new file mode 100644 index 0000000000..4c7721f9b4 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.js @@ -0,0 +1,35 @@ +//// [blockScopedSameNameFunctionDeclarationES5.ts] +function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationES5.js] +function foo(a) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt new file mode 100644 index 0000000000..5d15278f09 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(3,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(8,18): error TS2393: Duplicate function implementation. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(10,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(12,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts (6 errors) ==== + function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // duplicate + ~~~ +!!! error TS2393: Duplicate function implementation. + foo(); + foo(10);// not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + foo(); + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js new file mode 100644 index 0000000000..c793b74c60 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.js @@ -0,0 +1,35 @@ +//// [blockScopedSameNameFunctionDeclarationES6.ts] +function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10);// not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationES6.js] +function foo(a) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt new file mode 100644 index 0000000000..36ce2d8c48 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt @@ -0,0 +1,38 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(4,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(6,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(9,18): error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(11,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(14,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts (6 errors) ==== + "use strict"; + function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + ~~~ +!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } // Error to declare function in block scope + ~~~ +!!! error TS1250: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js new file mode 100644 index 0000000000..b51be0493c --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.js @@ -0,0 +1,37 @@ +//// [blockScopedSameNameFunctionDeclarationStrictES5.ts] +"use strict"; +function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationStrictES5.js] +"use strict"; +function foo(a) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt new file mode 100644 index 0000000000..7b8834c559 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(6,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(11,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(14,5): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts (4 errors) ==== + "use strict"; + function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + else { + function foo() { } + foo(); + foo(10); // not ok + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + } + foo(10); + foo(); // not ok - needs number + ~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js new file mode 100644 index 0000000000..863df86c03 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.js @@ -0,0 +1,37 @@ +//// [blockScopedSameNameFunctionDeclarationStrictES6.ts] +"use strict"; +function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number + +//// [blockScopedSameNameFunctionDeclarationStrictES6.js] +"use strict"; +function foo(a) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts new file mode 100644 index 0000000000..a5e10d19af --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts @@ -0,0 +1,17 @@ +// @target: ES5 +function foo(a: number) { + if (a === 1) { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate function + foo(); + foo(10); // not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts new file mode 100644 index 0000000000..c97e50964e --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts @@ -0,0 +1,17 @@ +// @target: ES6 +function foo(a: number) { + if (a === 10) { + function foo() { } // duplicate + foo(); + foo(10); // not ok + } + else { + function foo() { } // duplicate + foo(); + foo(10);// not ok + } + foo(10); // not ok + foo(); +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts new file mode 100644 index 0000000000..a0073c75d4 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts @@ -0,0 +1,18 @@ +// @target: ES5 +"use strict"; +function foo(a: number) { + if (a === 1) { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + else { + function foo() { } // Error to declare function in block scope + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok - needs number +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts new file mode 100644 index 0000000000..34d73a0520 --- /dev/null +++ b/tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts @@ -0,0 +1,18 @@ +// @target: ES6 +"use strict"; +function foo(a: number) { + if (a === 10) { + function foo() { } + foo(); + foo(10); // not ok + } + else { + function foo() { } + foo(); + foo(10); // not ok + } + foo(10); + foo(); // not ok +} +foo(10); +foo(); // not ok - needs number \ No newline at end of file