From cf5aadb28d22852963e9afc577020050aa276d82 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 30 Jan 2015 12:20:21 -0800 Subject: [PATCH] Address code review --- src/compiler/checker.ts | 9 ++------- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- ...mitArrowFunctionWhenUsingArguments.errors.txt | 16 ++++++++-------- ...ArrowFunctionWhenUsingArgumentsES6.errors.txt | 16 ++++++++-------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b531090b160..ab5bc93512b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4856,7 +4856,7 @@ module ts { // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction) { - error(node, Diagnostics.An_argument_object_has_different_behaviour_across_Javascript_versions_Use_function_expression_or_rest_parameters_instead); + error(node, Diagnostics.The_argument_object_has_different_behaviour_across_Javascript_versions_Use_function_expression_or_rest_parameters_instead); } if (symbol.flags & SymbolFlags.Import) { @@ -4915,12 +4915,7 @@ module ts { container = getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - if (compilerOptions.target >= ScriptTarget.ES6) { - needToCaptureLexicalThis = false; - } - else { - needToCaptureLexicalThis = true; - } + needToCaptureLexicalThis = !(compilerOptions.target >= ScriptTarget.ES6); } switch (container.kind) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5f9c0a2d4fc..cb6b9098864 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -452,6 +452,6 @@ module ts { You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported.", isEarly: true }, - An_argument_object_has_different_behaviour_across_Javascript_versions_Use_function_expression_or_rest_parameters_instead: { code: 9002, category: DiagnosticCategory.Error, key: "An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead" }, + The_argument_object_has_different_behaviour_across_Javascript_versions_Use_function_expression_or_rest_parameters_instead: { code: 9002, category: DiagnosticCategory.Error, key: "The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead" }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b5763adf47e..f3880aa545f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1909,7 +1909,7 @@ "code": 9001, "isEarly": true }, - "An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead": { + "The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead": { "category": "Error", "code": 9002 } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt index 714d6a3e46f..ea5e4ca1df1 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments.errors.txt @@ -1,21 +1,21 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(2,15): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(7,19): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(13,13): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(19,15): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(2,15): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(7,19): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(13,13): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts(19,15): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts (4 errors) ==== var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } var b = function () { var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } } @@ -23,7 +23,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts () => { var arg = arguments[0]; ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } } @@ -31,7 +31,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArguments.ts foo(() => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead }); function bar() { diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt b/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt index c134fb84958..060c1a6d3f4 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArgumentsES6.errors.txt @@ -1,21 +1,21 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(2,15): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(7,19): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(13,13): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(19,15): error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(2,15): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(7,19): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(13,13): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts(19,15): error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6.ts (4 errors) ==== var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } var b = function () { var a = () => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } } @@ -23,7 +23,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6 () => { var arg = arguments[0]; ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead } } @@ -31,7 +31,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionWhenUsingArgumentsES6 foo(() => { var arg = arguments[0]; // error ~~~~~~~~~ -!!! error TS9002: An argument object has different behaviour across Javascript versions. Use function expression or rest parameters instead +!!! error TS9002: The 'argument' object has different behaviour across Javascript versions. Use function expression or rest parameters instead }); function bar() {