From dd16fed21e5cf96e87a27ce25c5fe3bdb3ece9f0 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 10 Mar 2015 17:11:25 -0400 Subject: [PATCH] Perform error reporting in checker --- src/compiler/checker.ts | 12 ++- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 + src/compiler/parser.ts | 14 ++- src/compiler/types.ts | 44 +++++----- .../baselines/reference/APISample_compile.js | 3 + .../reference/APISample_compile.types | 7 ++ tests/baselines/reference/APISample_linter.js | 3 + .../reference/APISample_linter.types | 7 ++ .../reference/APISample_transform.js | 3 + .../reference/APISample_transform.types | 7 ++ .../baselines/reference/APISample_watcher.js | 3 + .../reference/APISample_watcher.types | 7 ++ ...sallowLineTerminatorBeforeArrow.errors.txt | 86 +++++++++---------- .../disallowLineTerminatorBeforeArrow.js | 70 ++++++++------- 15 files changed, 166 insertions(+), 105 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0dacb20ece4..dae254253ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11377,7 +11377,17 @@ module ts { function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { // Prevent cascading error by short-circuit - return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node); + } + + function checkGrammarArrowFunction(node: FunctionLikeDeclaration): boolean { + if (node.kind === SyntaxKind.ArrowFunction) { + if ((node).lineTerminatorBeforeArrow) { + grammarErrorOnNode(node, Diagnostics.Line_terminator_not_permitted_before_arrow); + return true; + } + } + return false; } function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d40fcd25ce0..556df1565b0 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -157,6 +157,7 @@ module ts { Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, + Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c4121e92251..0c00d8c974c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -619,6 +619,10 @@ "category": "Error", "code": 1199 }, + "Line terminator not permitted before arrow.": { + "category": "Error", + "code": 1200 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fc02c3f3eef..06655b1d822 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2918,7 +2918,7 @@ module ts { // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === SyntaxKind.Identifier && token === SyntaxKind.EqualsGreaterThanToken && !scanner.hasPrecedingLineBreak()) { + if (expr.kind === SyntaxKind.Identifier && token === SyntaxKind.EqualsGreaterThanToken) { return parseSimpleArrowFunctionExpression(expr); } @@ -3007,7 +3007,7 @@ module ts { Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); let node = createNode(SyntaxKind.ArrowFunction, identifier.pos); - + let parameter = createNode(SyntaxKind.Parameter, identifier.pos); parameter.name = identifier; finishNode(parameter); @@ -3016,6 +3016,7 @@ module ts { node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; + node.lineTerminatorBeforeArrow = scanner.hasPrecedingLineBreak(); parseExpected(SyntaxKind.EqualsGreaterThanToken); node.body = parseArrowFunctionExpressionBody(); @@ -3140,8 +3141,8 @@ module ts { } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): FunctionExpression { - let node = createNode(SyntaxKind.ArrowFunction); - // Arrow functions are never generators. + let node = createNode(SyntaxKind.ArrowFunction); + // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then // we have to have a complete parameter list. Otherwise we might see something like @@ -3168,10 +3169,7 @@ module ts { return undefined; } - // Must be no line terminator before token `=>`. - if (scanner.hasPrecedingLineBreak()) { - return undefined; - } + node.lineTerminatorBeforeArrow = scanner.hasPrecedingLineBreak(); return node; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c43591911ab..56820a10924 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -329,7 +329,7 @@ module ts { // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the - // error. + // error. ThisNodeHasError = 1 << 4, // Context flags set directly by the parser. @@ -337,7 +337,7 @@ module ts { // Context flags computed by aggregating child flags upwards. - // Used during incremental parsing to determine if this node or any of its children had an + // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. ThisNodeOrAnySubNodesHasError = 1 << 5, @@ -354,7 +354,7 @@ module ts { export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; - // Specific context the parser was in when this node was created. Normally undefined. + // Specific context the parser was in when this node was created. Normally undefined. // Only set when the parser was in some interesting context (like async/yield). parserContextFlags?: ParserContextFlags; modifiers?: ModifiersArray; // Array of modifiers @@ -524,7 +524,7 @@ module ts { body?: Block; } - // See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a + // See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a // ClassElement and an ObjectLiteralElement. export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { _accessorDeclarationBrand: any; @@ -575,12 +575,12 @@ module ts { export interface StringLiteralTypeNode extends LiteralExpression, TypeNode { } - // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. + // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. // Consider 'Expression'. Without the brand, 'Expression' is actually no different // (structurally) than 'Node'. Because of this you can pass any Node to a function that // takes an Expression without any error. By using the 'brands' we ensure that the type - // checker actually thinks you have something of the right type. Note: the brands are - // never actually given values. At runtime they have zero cost. + // checker actually thinks you have something of the right type. Note: the brands are + // never actually given values. At runtime they have zero cost. export interface Expression extends Node { _expressionBrand: any; @@ -653,6 +653,10 @@ module ts { body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional } + export interface ArrowFunctionExpression extends FunctionExpression { + lineTerminatorBeforeArrow: boolean; + } + // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, // or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. // For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". @@ -735,7 +739,7 @@ module ts { } export interface VariableStatement extends Statement { - declarationList: VariableDeclarationList; + declarationList: VariableDeclarationList; } export interface ExpressionStatement extends Statement { @@ -903,7 +907,7 @@ module ts { moduleSpecifier: Expression; } - // In case of: + // In case of: // import d from "mod" => name = d, namedBinding = undefined // import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns } // import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns } @@ -969,7 +973,7 @@ module ts { externalModuleIndicator: Node; languageVersion: ScriptTarget; identifiers: Map; - + /* @internal */ nodeCount: number; /* @internal */ identifierCount: number; /* @internal */ symbolCount: number; @@ -977,10 +981,10 @@ module ts { // File level diagnostics reported by the parser (includes diagnostics about /// references // as well as code diagnostics). /* @internal */ parseDiagnostics: Diagnostic[]; - + // File level diagnostics reported by the binder. /* @internal */ bindDiagnostics: Diagnostic[]; - + // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. /* @internal */ lineMap: number[]; @@ -1000,10 +1004,10 @@ module ts { getSourceFiles(): SourceFile[]; /** - * Emits the javascript and declaration files. If targetSourceFile is not specified, then + * Emits the javascript and declaration files. If targetSourceFile is not specified, then * the javascript and declaration files will be produced for all the files in this program. * If targetSourceFile is specified, then only the javascript and declaration for that - * specific file will be generated. + * specific file will be generated. * * If writeFile is not specified then the writeFile callback from the compiler host will be * used for writing the javascript and declaration files. Otherwise, the writeFile parameter @@ -1021,7 +1025,7 @@ module ts { getCommonSourceDirectory(): string; - // For testing purposes only. Should not be used by any other consumers (including the + // For testing purposes only. Should not be used by any other consumers (including the // language service). /* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker; @@ -1058,7 +1062,7 @@ module ts { // when -version or -help was provided, or this was a normal compilation, no diagnostics // were produced, and all outputs were generated successfully. Success = 0, - + // Diagnostics were produced and because of them no code was generated. DiagnosticsPresent_OutputsSkipped = 1, @@ -1168,12 +1172,12 @@ module ts { // Write symbols's type argument if it is instantiated symbol // eg. class C { p: T } <-- Show p as C.p here - // var a: C; + // var a: C; // var p = a.p; <--- Here p is property of C so show it as C.p instead of just C.p - WriteTypeParametersOrArguments = 0x00000001, + WriteTypeParametersOrArguments = 0x00000001, // Use only external alias information to get the symbol name in the given context - // eg. module m { export class c { } } import x = m.c; + // eg. module m { export class c { } } import x = m.c; // When this flag is specified m.c will be used to refer to the class instead of alias symbol x UseOnlyExternalAliasing = 0x00000002, } @@ -1778,7 +1782,7 @@ module ts { // Gets a count of how many times this collection has been modified. This value changes // each time 'add' is called (regardless of whether or not an equivalent diagnostic was // already in the collection). As such, it can be used as a simple way to tell if any - // operation caused diagnostics to be returned by storing and comparing the return value + // operation caused diagnostics to be returned by storing and comparing the return value // of this method before/after the operation is performed. getModificationCount(): number; } diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 98571823181..316649a35c9 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -553,6 +553,9 @@ declare module "typescript" { name?: Identifier; body: Block | Expression; } + interface ArrowFunctionExpression extends FunctionExpression { + lineTerminatorBeforeArrow: boolean; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 087c0389d0f..bf51bb946c0 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -1668,6 +1668,13 @@ declare module "typescript" { >body : Expression | Block >Block : Block >Expression : Expression + } + interface ArrowFunctionExpression extends FunctionExpression { +>ArrowFunctionExpression : ArrowFunctionExpression +>FunctionExpression : FunctionExpression + + lineTerminatorBeforeArrow: boolean; +>lineTerminatorBeforeArrow : boolean } interface LiteralExpression extends PrimaryExpression { >LiteralExpression : LiteralExpression diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index d43d6220072..5f7dc308820 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -584,6 +584,9 @@ declare module "typescript" { name?: Identifier; body: Block | Expression; } + interface ArrowFunctionExpression extends FunctionExpression { + lineTerminatorBeforeArrow: boolean; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 14eb2936242..ede73749eb0 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -1814,6 +1814,13 @@ declare module "typescript" { >body : Expression | Block >Block : Block >Expression : Expression + } + interface ArrowFunctionExpression extends FunctionExpression { +>ArrowFunctionExpression : ArrowFunctionExpression +>FunctionExpression : FunctionExpression + + lineTerminatorBeforeArrow: boolean; +>lineTerminatorBeforeArrow : boolean } interface LiteralExpression extends PrimaryExpression { >LiteralExpression : LiteralExpression diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index bfe62135a0d..2d39e9a3c0c 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -585,6 +585,9 @@ declare module "typescript" { name?: Identifier; body: Block | Expression; } + interface ArrowFunctionExpression extends FunctionExpression { + lineTerminatorBeforeArrow: boolean; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index baa497c95fa..d9d1482fbc8 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -1764,6 +1764,13 @@ declare module "typescript" { >body : Expression | Block >Block : Block >Expression : Expression + } + interface ArrowFunctionExpression extends FunctionExpression { +>ArrowFunctionExpression : ArrowFunctionExpression +>FunctionExpression : FunctionExpression + + lineTerminatorBeforeArrow: boolean; +>lineTerminatorBeforeArrow : boolean } interface LiteralExpression extends PrimaryExpression { >LiteralExpression : LiteralExpression diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index ee1fd062515..7fa2a92afae 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -622,6 +622,9 @@ declare module "typescript" { name?: Identifier; body: Block | Expression; } + interface ArrowFunctionExpression extends FunctionExpression { + lineTerminatorBeforeArrow: boolean; + } interface LiteralExpression extends PrimaryExpression { text: string; isUnterminated?: boolean; diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index a8b534439d5..23f7ffb7148 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -1937,6 +1937,13 @@ declare module "typescript" { >body : Expression | Block >Block : Block >Expression : Expression + } + interface ArrowFunctionExpression extends FunctionExpression { +>ArrowFunctionExpression : ArrowFunctionExpression +>FunctionExpression : FunctionExpression + + lineTerminatorBeforeArrow: boolean; +>lineTerminatorBeforeArrow : boolean } interface LiteralExpression extends PrimaryExpression { >LiteralExpression : LiteralExpression diff --git a/tests/baselines/reference/disallowLineTerminatorBeforeArrow.errors.txt b/tests/baselines/reference/disallowLineTerminatorBeforeArrow.errors.txt index 0450903f717..c64d42b7fff 100644 --- a/tests/baselines/reference/disallowLineTerminatorBeforeArrow.errors.txt +++ b/tests/baselines/reference/disallowLineTerminatorBeforeArrow.errors.txt @@ -1,70 +1,66 @@ -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(2,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(4,7): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(6,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(8,7): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(10,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(12,7): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(14,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(16,7): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(19,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(20,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(21,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(22,5): error TS1109: Expression expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(22,17): error TS1005: ':' expected. -tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(22,22): error TS1005: ',' expected. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(1,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(3,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(5,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(7,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(9,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(11,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(13,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(15,10): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(19,5): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts(21,5): error TS1200: Line terminator not permitted before arrow. -==== tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts (14 errors) ==== +==== tests/cases/conformance/es6/arrowFunction/disallowLineTerminatorBeforeArrow.ts (10 errors) ==== var f1 = () + ~~ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f2 = (x: string, y: string) /* + ~~~~~~~~~~~~~~~~~~~~~~~~~ */ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f3 = (x: string, y: number, ...rest) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f4 = (x: string, y: number, ...rest) /* + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f5 = (...rest) + ~~~~~~~~~ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f6 = (...rest) /* + ~~~~~~~~~~~~ */ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f7 = (x: string, y: number, z = 10) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. var f8 = (x: string, y: number, z = 10) /* + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ => { } - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. function foo(func: () => boolean) { } foo(() - ~~~~~~ + ~~ => true); - ~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - ~~ -!!! error TS1109: Expression expected. + ~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. foo(() - ~~~~~~ - => { return false; }); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. ~~ -!!! error TS1109: Expression expected. - ~~~~~ -!!! error TS1005: ':' expected. - ~ -!!! error TS1005: ',' expected. + => { return false; }); + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1200: Line terminator not permitted before arrow. \ No newline at end of file diff --git a/tests/baselines/reference/disallowLineTerminatorBeforeArrow.js b/tests/baselines/reference/disallowLineTerminatorBeforeArrow.js index c98b6a89d4f..2619b41bf38 100644 --- a/tests/baselines/reference/disallowLineTerminatorBeforeArrow.js +++ b/tests/baselines/reference/disallowLineTerminatorBeforeArrow.js @@ -24,37 +24,45 @@ foo(() //// [disallowLineTerminatorBeforeArrow.js] -var f1 = ; -{ -} -var f2 = ; /* - */ -{ -} -var f3 = ; -{ -} -var f4 = ; /* - */ -{ -} -var f5 = ; -{ -} -var f6 = ; /* - */ -{ -} -var f7 = ; -{ -} -var f8 = ; /* - */ -{ -} +var f1 = function () { +}; +var f2 = function (x, y) { +}; +var f3 = function (x, y) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +}; +var f4 = function (x, y) { + var rest = []; + for (var _i = 2; _i < arguments.length; _i++) { + rest[_i - 2] = arguments[_i]; + } +}; +var f5 = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +}; +var f6 = function () { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +}; +var f7 = function (x, y, z) { + if (z === void 0) { z = 10; } +}; +var f8 = function (x, y, z) { + if (z === void 0) { z = 10; } +}; function foo(func) { } -foo(, true); -foo(, { - return: false +foo(function () { + return true; +}); +foo(function () { + return false; });