direct isInAmbientContext
This commit is contained in:
parent
c1d851c7ec
commit
78ece7bfb1
12 changed files with 72 additions and 118 deletions
|
@ -2503,27 +2503,8 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function needParameterStrictModeCheck(node: Node) {
|
||||
if (node.parent.kind === SyntaxKind.ConstructorType || node.parent.kind === SyntaxKind.FunctionType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node.parent.parent && (
|
||||
node.parent.parent.kind === SyntaxKind.InterfaceDeclaration ||
|
||||
node.parent.parent.kind === SyntaxKind.TypeLiteral
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isDeclarationFile(file) || isInAmbientContext(node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function bindParameter(node: ParameterDeclaration) {
|
||||
if (inStrictMode && needParameterStrictModeCheck(node)) {
|
||||
if (inStrictMode && !isInAmbientContext(node)) {
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
||||
checkStrictModeEvalOrArguments(node, node.name);
|
||||
|
|
|
@ -51,12 +51,9 @@ tests/cases/compiler/collisionArgumentsFunction.ts(30,22): error TS2396: Duplica
|
|||
var arguments: any; // No error
|
||||
}
|
||||
|
||||
namespace strict {
|
||||
"use strict";
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
||||
}
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
|
@ -37,15 +37,12 @@ function f4NoError(arguments: any) { // no error
|
|||
var arguments: any; // No error
|
||||
}
|
||||
|
||||
namespace strict {
|
||||
"use strict";
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
||||
}
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
||||
|
||||
//// [collisionArgumentsFunction.js]
|
||||
// Functions
|
||||
|
@ -93,7 +90,3 @@ function f42(i) {
|
|||
function f4NoError(arguments) {
|
||||
var arguments; // No error
|
||||
}
|
||||
var strict;
|
||||
(function (strict) {
|
||||
"use strict";
|
||||
})(strict || (strict = {}));
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//// [collisionArgumentsInType.ts]
|
||||
"use strict";
|
||||
var v1: (i: number, ...arguments) => void; // no error - no code gen
|
||||
var v12: (arguments: number, ...restParameters) => void; // no error - no code gen
|
||||
var v2: {
|
||||
|
@ -16,7 +15,6 @@ var v21: {
|
|||
}
|
||||
|
||||
//// [collisionArgumentsInType.js]
|
||||
"use strict";
|
||||
var v1; // no error - no code gen
|
||||
var v12; // no error - no code gen
|
||||
var v2;
|
||||
|
|
|
@ -1,54 +1,53 @@
|
|||
=== tests/cases/compiler/collisionArgumentsInType.ts ===
|
||||
"use strict";
|
||||
var v1: (i: number, ...arguments) => void; // no error - no code gen
|
||||
>v1 : Symbol(v1, Decl(collisionArgumentsInType.ts, 1, 3))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 1, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 1, 19))
|
||||
>v1 : Symbol(v1, Decl(collisionArgumentsInType.ts, 0, 3))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 0, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 0, 19))
|
||||
|
||||
var v12: (arguments: number, ...restParameters) => void; // no error - no code gen
|
||||
>v12 : Symbol(v12, Decl(collisionArgumentsInType.ts, 2, 3))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 2, 10))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 2, 28))
|
||||
>v12 : Symbol(v12, Decl(collisionArgumentsInType.ts, 1, 3))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 1, 10))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 1, 28))
|
||||
|
||||
var v2: {
|
||||
>v2 : Symbol(v2, Decl(collisionArgumentsInType.ts, 3, 3))
|
||||
>v2 : Symbol(v2, Decl(collisionArgumentsInType.ts, 2, 3))
|
||||
|
||||
(arguments: number, ...restParameters); // no error - no code gen
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 4, 5))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 4, 23))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 3, 5))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 3, 23))
|
||||
|
||||
new (arguments: number, ...restParameters); // no error - no code gen
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 5, 9))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 5, 27))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 4, 9))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 4, 27))
|
||||
|
||||
foo(arguments: number, ...restParameters); // no error - no code gen
|
||||
>foo : Symbol(foo, Decl(collisionArgumentsInType.ts, 5, 47))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 6, 8))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 6, 26))
|
||||
>foo : Symbol(foo, Decl(collisionArgumentsInType.ts, 4, 47))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 5, 8))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 5, 26))
|
||||
|
||||
prop: (arguments: number, ...restParameters) => void; // no error - no code gen
|
||||
>prop : Symbol(prop, Decl(collisionArgumentsInType.ts, 6, 46))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 7, 11))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 7, 29))
|
||||
>prop : Symbol(prop, Decl(collisionArgumentsInType.ts, 5, 46))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 6, 11))
|
||||
>restParameters : Symbol(restParameters, Decl(collisionArgumentsInType.ts, 6, 29))
|
||||
}
|
||||
var v21: {
|
||||
>v21 : Symbol(v21, Decl(collisionArgumentsInType.ts, 9, 3))
|
||||
>v21 : Symbol(v21, Decl(collisionArgumentsInType.ts, 8, 3))
|
||||
|
||||
(i: number, ...arguments); // no error - no code gen
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 10, 5))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 10, 15))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 9, 5))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 9, 15))
|
||||
|
||||
new (i: number, ...arguments); // no error - no code gen
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 11, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 11, 19))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 10, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 10, 19))
|
||||
|
||||
foo(i: number, ...arguments); // no error - no code gen
|
||||
>foo : Symbol(foo, Decl(collisionArgumentsInType.ts, 11, 34))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 12, 8))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 12, 18))
|
||||
>foo : Symbol(foo, Decl(collisionArgumentsInType.ts, 10, 34))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 11, 8))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 11, 18))
|
||||
|
||||
prop: (i: number, ...arguments) => void; // no error - no code gen
|
||||
>prop : Symbol(prop, Decl(collisionArgumentsInType.ts, 12, 33))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 13, 11))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 13, 21))
|
||||
>prop : Symbol(prop, Decl(collisionArgumentsInType.ts, 11, 33))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInType.ts, 12, 11))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInType.ts, 12, 21))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
=== tests/cases/compiler/collisionArgumentsInType.ts ===
|
||||
"use strict";
|
||||
>"use strict" : "use strict"
|
||||
|
||||
var v1: (i: number, ...arguments) => void; // no error - no code gen
|
||||
>v1 : (i: number, ...arguments: any[]) => void
|
||||
>i : number
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//// [collisionArgumentsInterfaceMembers.ts]
|
||||
"use strict";
|
||||
// call
|
||||
interface i1 {
|
||||
(i: number, ...arguments); // no error - no code gen
|
||||
|
@ -30,4 +29,3 @@ interface i3 {
|
|||
}
|
||||
|
||||
//// [collisionArgumentsInterfaceMembers.js]
|
||||
"use strict";
|
||||
|
|
|
@ -1,64 +1,63 @@
|
|||
=== tests/cases/compiler/collisionArgumentsInterfaceMembers.ts ===
|
||||
"use strict";
|
||||
// call
|
||||
interface i1 {
|
||||
>i1 : Symbol(i1, Decl(collisionArgumentsInterfaceMembers.ts, 0, 13))
|
||||
>i1 : Symbol(i1, Decl(collisionArgumentsInterfaceMembers.ts, 0, 0))
|
||||
|
||||
(i: number, ...arguments); // no error - no code gen
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 3, 5))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 3, 15))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 2, 5))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 2, 15))
|
||||
}
|
||||
interface i12 {
|
||||
>i12 : Symbol(i12, Decl(collisionArgumentsInterfaceMembers.ts, 4, 1))
|
||||
>i12 : Symbol(i12, Decl(collisionArgumentsInterfaceMembers.ts, 3, 1))
|
||||
|
||||
(arguments: number, ...rest); // no error - no code gen
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 6, 5))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 6, 23))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 5, 5))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 5, 23))
|
||||
}
|
||||
interface i1NoError {
|
||||
>i1NoError : Symbol(i1NoError, Decl(collisionArgumentsInterfaceMembers.ts, 7, 1))
|
||||
>i1NoError : Symbol(i1NoError, Decl(collisionArgumentsInterfaceMembers.ts, 6, 1))
|
||||
|
||||
(arguments: number); // no error
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 9, 5))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 8, 5))
|
||||
}
|
||||
|
||||
// new
|
||||
interface i2 {
|
||||
>i2 : Symbol(i2, Decl(collisionArgumentsInterfaceMembers.ts, 10, 1))
|
||||
>i2 : Symbol(i2, Decl(collisionArgumentsInterfaceMembers.ts, 9, 1))
|
||||
|
||||
new (i: number, ...arguments); // no error - no code gen
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 14, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 14, 19))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 13, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 13, 19))
|
||||
}
|
||||
interface i21 {
|
||||
>i21 : Symbol(i21, Decl(collisionArgumentsInterfaceMembers.ts, 15, 1))
|
||||
>i21 : Symbol(i21, Decl(collisionArgumentsInterfaceMembers.ts, 14, 1))
|
||||
|
||||
new (arguments: number, ...rest); // no error - no code gen
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 17, 9))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 17, 27))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 16, 9))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 16, 27))
|
||||
}
|
||||
interface i2NoError {
|
||||
>i2NoError : Symbol(i2NoError, Decl(collisionArgumentsInterfaceMembers.ts, 18, 1))
|
||||
>i2NoError : Symbol(i2NoError, Decl(collisionArgumentsInterfaceMembers.ts, 17, 1))
|
||||
|
||||
new (arguments: number); // no error
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 20, 9))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 19, 9))
|
||||
}
|
||||
|
||||
// method
|
||||
interface i3 {
|
||||
>i3 : Symbol(i3, Decl(collisionArgumentsInterfaceMembers.ts, 21, 1))
|
||||
>i3 : Symbol(i3, Decl(collisionArgumentsInterfaceMembers.ts, 20, 1))
|
||||
|
||||
foo(i: number, ...arguments); // no error - no code gen
|
||||
>foo : Symbol(i3.foo, Decl(collisionArgumentsInterfaceMembers.ts, 24, 14))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 25, 8))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 25, 18))
|
||||
>foo : Symbol(i3.foo, Decl(collisionArgumentsInterfaceMembers.ts, 23, 14))
|
||||
>i : Symbol(i, Decl(collisionArgumentsInterfaceMembers.ts, 24, 8))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 24, 18))
|
||||
|
||||
foo1(arguments: number, ...rest); // no error - no code gen
|
||||
>foo1 : Symbol(i3.foo1, Decl(collisionArgumentsInterfaceMembers.ts, 25, 33))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 26, 9))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 26, 27))
|
||||
>foo1 : Symbol(i3.foo1, Decl(collisionArgumentsInterfaceMembers.ts, 24, 33))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 25, 9))
|
||||
>rest : Symbol(rest, Decl(collisionArgumentsInterfaceMembers.ts, 25, 27))
|
||||
|
||||
fooNoError(arguments: number); // no error
|
||||
>fooNoError : Symbol(i3.fooNoError, Decl(collisionArgumentsInterfaceMembers.ts, 26, 37))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 27, 15))
|
||||
>fooNoError : Symbol(i3.fooNoError, Decl(collisionArgumentsInterfaceMembers.ts, 25, 37))
|
||||
>arguments : Symbol(arguments, Decl(collisionArgumentsInterfaceMembers.ts, 26, 15))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
=== tests/cases/compiler/collisionArgumentsInterfaceMembers.ts ===
|
||||
"use strict";
|
||||
>"use strict" : "use strict"
|
||||
|
||||
// call
|
||||
interface i1 {
|
||||
>i1 : i1
|
||||
|
|
|
@ -36,12 +36,9 @@ function f4NoError(arguments: any) { // no error
|
|||
var arguments: any; // No error
|
||||
}
|
||||
|
||||
namespace strict {
|
||||
"use strict";
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
||||
}
|
||||
declare function f5(arguments: number, ...rest); // no codegen no error
|
||||
declare function f5(arguments: string, ...rest); // no codegen no error
|
||||
declare function f52(i: number, ...arguments); // no codegen no error
|
||||
declare function f52(i: string, ...arguments); // no codegen no error
|
||||
declare function f6(arguments: number); // no codegen no error
|
||||
declare function f6(arguments: string); // no codegen no error
|
|
@ -1,4 +1,3 @@
|
|||
"use strict";
|
||||
var v1: (i: number, ...arguments) => void; // no error - no code gen
|
||||
var v12: (arguments: number, ...restParameters) => void; // no error - no code gen
|
||||
var v2: {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
"use strict";
|
||||
// call
|
||||
interface i1 {
|
||||
(i: number, ...arguments); // no error - no code gen
|
||||
|
|
Loading…
Reference in a new issue