parent
94d7e30393
commit
635780db07
|
@ -1419,12 +1419,18 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
||||
// for lower compile targets the resolved symbol is used to emit an error
|
||||
if (compilerOptions.target! >= ScriptTarget.ES2015) {
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (meaning & SymbolFlags.Variable && name === "arguments") {
|
||||
result = argumentsSymbol;
|
||||
break loop;
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
tests/cases/compiler/arguments.ts(6,25): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(7,23): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(8,19): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(9,23): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(10,34): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(6,8): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(9,25): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(10,23): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(11,19): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(12,23): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/compiler/arguments.ts(13,34): error TS2304: Cannot find name 'arguments'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arguments.ts (5 errors) ====
|
||||
==== tests/cases/compiler/arguments.ts (6 errors) ====
|
||||
function f() {
|
||||
var x=arguments[12];
|
||||
(() => arguments)();
|
||||
}
|
||||
|
||||
(() => arguments)();
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'arguments'.
|
||||
|
||||
interface I {
|
||||
method(args: typeof arguments): void;
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
//// [arguments.ts]
|
||||
function f() {
|
||||
var x=arguments[12];
|
||||
(() => arguments)();
|
||||
}
|
||||
|
||||
(() => arguments)();
|
||||
|
||||
interface I {
|
||||
method(args: typeof arguments): void;
|
||||
fn: (args: typeof arguments) => void;
|
||||
|
@ -14,4 +17,6 @@ interface I {
|
|||
//// [arguments.js]
|
||||
function f() {
|
||||
var x = arguments[12];
|
||||
(() => arguments)();
|
||||
}
|
||||
(() => arguments)();
|
||||
|
|
|
@ -4,27 +4,32 @@ function f() {
|
|||
|
||||
var x=arguments[12];
|
||||
>x : Symbol(x, Decl(arguments.ts, 1, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
|
||||
(() => arguments)();
|
||||
>arguments : Symbol(arguments)
|
||||
}
|
||||
|
||||
(() => arguments)();
|
||||
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(arguments.ts, 2, 1))
|
||||
>I : Symbol(I, Decl(arguments.ts, 5, 20))
|
||||
|
||||
method(args: typeof arguments): void;
|
||||
>method : Symbol(I.method, Decl(arguments.ts, 4, 13))
|
||||
>args : Symbol(args, Decl(arguments.ts, 5, 11))
|
||||
>method : Symbol(I.method, Decl(arguments.ts, 7, 13))
|
||||
>args : Symbol(args, Decl(arguments.ts, 8, 11))
|
||||
|
||||
fn: (args: typeof arguments) => void;
|
||||
>fn : Symbol(I.fn, Decl(arguments.ts, 5, 41))
|
||||
>args : Symbol(args, Decl(arguments.ts, 6, 9))
|
||||
>fn : Symbol(I.fn, Decl(arguments.ts, 8, 41))
|
||||
>args : Symbol(args, Decl(arguments.ts, 9, 9))
|
||||
|
||||
(args: typeof arguments): void;
|
||||
>args : Symbol(args, Decl(arguments.ts, 7, 5))
|
||||
>args : Symbol(args, Decl(arguments.ts, 10, 5))
|
||||
|
||||
new (args: typeof arguments): void;
|
||||
>args : Symbol(args, Decl(arguments.ts, 8, 9))
|
||||
>args : Symbol(args, Decl(arguments.ts, 11, 9))
|
||||
|
||||
construct: new (args: typeof arguments) => void;
|
||||
>construct : Symbol(I.construct, Decl(arguments.ts, 8, 39))
|
||||
>args : Symbol(args, Decl(arguments.ts, 9, 20))
|
||||
>construct : Symbol(I.construct, Decl(arguments.ts, 11, 39))
|
||||
>args : Symbol(args, Decl(arguments.ts, 12, 20))
|
||||
}
|
||||
|
|
|
@ -7,8 +7,20 @@ function f() {
|
|||
>arguments[12] : any
|
||||
>arguments : IArguments
|
||||
>12 : 12
|
||||
|
||||
(() => arguments)();
|
||||
>(() => arguments)() : IArguments
|
||||
>(() => arguments) : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
}
|
||||
|
||||
(() => arguments)();
|
||||
>(() => arguments)() : any
|
||||
>(() => arguments) : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
|
||||
interface I {
|
||||
method(args: typeof arguments): void;
|
||||
>method : (args: any) => void
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments01_ES6.ts(2,15): error TS2304: Cannot find name 'arguments'.
|
||||
tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments01_ES6.ts(19,15): error TS2304: Cannot find name 'arguments'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments01_ES6.ts (2 errors) ====
|
||||
var a = () => {
|
||||
var arg = arguments[0]; // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'arguments'.
|
||||
}
|
||||
|
||||
var b = function () {
|
||||
var a = () => {
|
||||
var arg = arguments[0]; // error
|
||||
}
|
||||
}
|
||||
|
||||
function baz() {
|
||||
() => {
|
||||
var arg = arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
function foo(inputFunc: () => void) { }
|
||||
foo(() => {
|
||||
var arg = arguments[0]; // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'arguments'.
|
||||
});
|
||||
|
||||
function bar() {
|
||||
var arg = arguments[0]; // no error
|
||||
}
|
||||
|
||||
|
||||
() => {
|
||||
function foo() {
|
||||
var arg = arguments[0]; // no error
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ var a = () => {
|
|||
|
||||
var arg = arguments[0]; // error
|
||||
>arg : Symbol(arg, Decl(emitArrowFunctionWhenUsingArguments01_ES6.ts, 1, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
}
|
||||
|
||||
var b = function () {
|
||||
|
@ -38,7 +37,6 @@ foo(() => {
|
|||
|
||||
var arg = arguments[0]; // error
|
||||
>arg : Symbol(arg, Decl(emitArrowFunctionWhenUsingArguments01_ES6.ts, 18, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ var a = () => {
|
|||
var arg = arguments[0]; // error
|
||||
>arg : any
|
||||
>arguments[0] : any
|
||||
>arguments : IArguments
|
||||
>arguments : any
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ foo(() => {
|
|||
var arg = arguments[0]; // error
|
||||
>arg : any
|
||||
>arguments[0] : any
|
||||
>arguments : IArguments
|
||||
>arguments : any
|
||||
>0 : 0
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments02_ES6.ts(1,15): error TS2304: Cannot find name 'arguments'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments02_ES6.ts (1 errors) ====
|
||||
var a = () => arguments;
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'arguments'.
|
|
@ -1,5 +1,4 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments02_ES6.ts ===
|
||||
var a = () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments02_ES6.ts, 0, 3))
|
||||
>arguments : Symbol(arguments)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments02_ES6.ts ===
|
||||
var a = () => arguments;
|
||||
>a : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
|
||||
|
|
|
@ -4,5 +4,5 @@ var arguments;
|
|||
|
||||
var a = () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments03_ES6.ts, 1, 3))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments03_ES6.ts, 0, 3))
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ var arguments;
|
|||
>arguments : any
|
||||
|
||||
var a = () => arguments;
|
||||
>a : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@ function f() {
|
|||
|
||||
var a = () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments04_ES6.ts, 2, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments04_ES6.ts, 1, 7))
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ function f() {
|
|||
>arguments : any
|
||||
|
||||
var a = () => arguments;
|
||||
>a : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ function f(arguments) {
|
|||
|
||||
var a = () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments05_ES6.ts, 1, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments05_ES6.ts, 0, 11))
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ function f(arguments) {
|
|||
>arguments : any
|
||||
|
||||
var a = () => arguments;
|
||||
>a : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ function f(arguments) {
|
|||
|
||||
var a = () => () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments06_ES6.ts, 1, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments06_ES6.ts, 0, 11))
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ function f(arguments) {
|
|||
>arguments : any
|
||||
|
||||
var a = () => () => arguments;
|
||||
>a : () => () => IArguments
|
||||
>() => () => arguments : () => () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => () => any
|
||||
>() => () => arguments : () => () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ function f(arguments) {
|
|||
var a = (arguments) => () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments07_ES6.ts, 1, 7))
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments07_ES6.ts, 1, 13))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments07_ES6.ts, 1, 13))
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ function f(arguments) {
|
|||
>arguments : any
|
||||
|
||||
var a = (arguments) => () => arguments;
|
||||
>a : (arguments: any) => () => IArguments
|
||||
>(arguments) => () => arguments : (arguments: any) => () => IArguments
|
||||
>a : (arguments: any) => () => any
|
||||
>(arguments) => () => arguments : (arguments: any) => () => any
|
||||
>arguments : any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ function f(arguments) {
|
|||
|
||||
var a = () => () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments11_ES6.ts, 2, 7))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments11_ES6.ts, 0, 11))
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ function f(arguments) {
|
|||
>10 : 10
|
||||
|
||||
var a = () => () => arguments;
|
||||
>a : () => () => IArguments
|
||||
>() => () => arguments : () => () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => () => any
|
||||
>() => () => arguments : () => () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ class C {
|
|||
|
||||
var a = () => arguments;
|
||||
>a : Symbol(a, Decl(emitArrowFunctionWhenUsingArguments12_ES6.ts, 2, 11))
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments12_ES6.ts, 1, 6))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ class C {
|
|||
>arguments : any
|
||||
|
||||
var a = () => arguments;
|
||||
>a : () => IArguments
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>a : () => any
|
||||
>() => arguments : () => any
|
||||
>arguments : any
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ function f() {
|
|||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments14_ES6.ts, 2, 11))
|
||||
|
||||
return () => arguments;
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments14_ES6.ts, 2, 11))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments14_ES6.ts ===
|
||||
function f() {
|
||||
>f : () => () => IArguments
|
||||
>f : () => () => number
|
||||
|
||||
if (Math.random()) {
|
||||
>Math.random() : number
|
||||
|
@ -13,7 +13,7 @@ function f() {
|
|||
>100 : 100
|
||||
|
||||
return () => arguments;
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>() => arguments : () => number
|
||||
>arguments : number
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ function f() {
|
|||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments15_ES6.ts, 3, 13))
|
||||
|
||||
return () => arguments;
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments15_ES6.ts, 3, 13))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments15_ES6.ts ===
|
||||
function f() {
|
||||
>f : () => () => IArguments
|
||||
>f : () => () => number
|
||||
|
||||
var arguments = "hello";
|
||||
>arguments : string
|
||||
|
@ -17,7 +17,7 @@ function f() {
|
|||
>100 : 100
|
||||
|
||||
return () => arguments;
|
||||
>() => arguments : () => IArguments
|
||||
>arguments : IArguments
|
||||
>() => arguments : () => number
|
||||
>arguments : 100
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ function f() {
|
|||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
return () => arguments[0];
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments16_ES6.ts, 1, 7), Decl(emitArrowFunctionWhenUsingArguments16_ES6.ts, 5, 7))
|
||||
}
|
||||
var arguments = "world";
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments16_ES6.ts, 1, 7), Decl(emitArrowFunctionWhenUsingArguments16_ES6.ts, 5, 7))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments16_ES6.ts ===
|
||||
function f() {
|
||||
>f : () => () => any
|
||||
>f : () => () => string
|
||||
|
||||
var arguments = "hello";
|
||||
>arguments : string
|
||||
|
@ -13,9 +13,9 @@ function f() {
|
|||
>random : () => number
|
||||
|
||||
return () => arguments[0];
|
||||
>() => arguments[0] : () => any
|
||||
>arguments[0] : any
|
||||
>arguments : IArguments
|
||||
>() => arguments[0] : () => string
|
||||
>arguments[0] : string
|
||||
>arguments : string
|
||||
>0 : 0
|
||||
}
|
||||
var arguments = "world";
|
||||
|
|
|
@ -12,7 +12,7 @@ function f() {
|
|||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
return () => arguments[0];
|
||||
>arguments : Symbol(arguments)
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments17_ES6.ts, 1, 9), Decl(emitArrowFunctionWhenUsingArguments17_ES6.ts, 5, 7))
|
||||
}
|
||||
var arguments = "world";
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments17_ES6.ts, 1, 9), Decl(emitArrowFunctionWhenUsingArguments17_ES6.ts, 5, 7))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments17_ES6.ts ===
|
||||
function f() {
|
||||
>f : () => () => any
|
||||
>f : () => () => string
|
||||
|
||||
var { arguments } = { arguments: "hello" };
|
||||
>arguments : string
|
||||
|
@ -15,9 +15,9 @@ function f() {
|
|||
>random : () => number
|
||||
|
||||
return () => arguments[0];
|
||||
>() => arguments[0] : () => any
|
||||
>arguments[0] : any
|
||||
>arguments : IArguments
|
||||
>() => arguments[0] : () => string
|
||||
>arguments[0] : string
|
||||
>arguments : string
|
||||
>0 : 0
|
||||
}
|
||||
var arguments = "world";
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
// @target: ES6
|
||||
function f() {
|
||||
var x=arguments[12];
|
||||
(() => arguments)();
|
||||
}
|
||||
|
||||
(() => arguments)();
|
||||
|
||||
interface I {
|
||||
method(args: typeof arguments): void;
|
||||
fn: (args: typeof arguments) => void;
|
||||
|
|
Loading…
Reference in a new issue