diff --git a/Jakefile b/Jakefile index a25fb8a9b0d60..981bd8076ff1e 100644 --- a/Jakefile +++ b/Jakefile @@ -306,6 +306,11 @@ function exec(cmd, completeHandler) { } complete(); }); + ex.addListener("error", function(e, status) { + process.stderr.write(status); + process.stderr.write(e); + complete(); + }) try{ ex.run(); } catch(e) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6a112ec06e2d0..3c994fc3fe44e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5284,7 +5284,7 @@ module ts { function checkWithStatement(node: WithStatement) { checkExpression(node.expression); - checkSourceElement(node.statement); + error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } function checkSwitchStatement(node: SwitchStatement) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 1abf98883468f..9927cb9d98ea2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -99,6 +99,9 @@ module ts { A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." }, A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1114, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1115, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1116, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, Duplicate_identifier_0: { code: 2000, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 2068, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, Multiple_constructor_implementations_are_not_allowed: { code: 2070, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, @@ -123,6 +126,7 @@ module ts { Setters_cannot_return_a_value: { code: 2122, category: DiagnosticCategory.Error, key: "Setters cannot return a value." }, Invalid_left_hand_side_of_assignment_expression: { code: 2130, category: DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2134, category: DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, + All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2135, category: DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2139, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, Overload_signatures_must_all_be_public_or_private: { code: 2150, category: DiagnosticCategory.Error, key: "Overload signatures must all be public or private." }, Overload_signatures_must_all_be_exported_or_not_exported: { code: 2151, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 58b6d41099842..d61be84b5deef 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -388,7 +388,18 @@ "category": "Error", "code": 1113 }, - + "An object literal cannot have multiple properties with the same name in strict mode.": { + "category": "Error", + "code": 1114 + }, + "An object literal cannot have multiple get/set accessors with the same name.": { + "category": "Error", + "code": 1115 + }, + "An object literal cannot have property and accessor with the same name.": { + "category": "Error", + "code": 1116 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2000 @@ -485,6 +496,10 @@ "category": "Error", "code": 2134 }, + "All symbols within a 'with' block will be resolved to 'any'.": { + "category": "Error", + "code": 2135 + }, "The operand of an increment or decrement operator must be a variable, property or indexer.": { "category": "Error", "code": 2139 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 90661c08fc0dd..d1e2367babb08 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1669,8 +1669,7 @@ module ts { function emitDirectivePrologues(statements: Statement[], startWithNewLine: boolean): number { for (var i = 0; i < statements.length; ++i) { - if (statements[i].kind === SyntaxKind.ExpressionStatement && - (statements[i]).expression.kind === SyntaxKind.StringLiteral) { + if (isPrologueDirective(statements[i])) { if (startWithNewLine || i > 0) { writeLine(); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0304586bbca2f..7afb044090936 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -119,6 +119,22 @@ module ts { return file.externalModuleIndicator !== undefined; } + export function isPrologueDirective(node: Node): boolean { + return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; + } + + function isEvalOrArgumentsIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && + (node).text && + ((node).text === "eval" || (node).text === "arguments") + } + + /// Should be called only on prologue directives (isPrologueDirective(node) should be true) + function isUseStrictPrologueDirective(node: Node): boolean { + Debug.assert(isPrologueDirective(node)); + return ((node).expression).text === "use strict"; + } + // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns @@ -383,6 +399,7 @@ module ts { var identifierCount = 0; var nodeCount = 0; var lineStarts: number[]; + var isInStrictMode = false; var lookAheadMode = LookAheadMode.NotLookingAhead; var inAmbientContext = false; @@ -418,6 +435,13 @@ module ts { file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); } + function reportInvalidUseInStrictMode(node: Identifier): void { + // identifierToString cannot be used here since it uses backreference to 'parent' that is not yet set + var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); + grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); + } + + function grammarErrorAtPos(start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { file.syntacticErrors.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); } @@ -522,7 +546,7 @@ module ts { } function isIdentifier(): boolean { - return token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord; + return token === SyntaxKind.Identifier || (isInStrictMode ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord); } function isSemicolon(): boolean { @@ -767,14 +791,28 @@ module ts { } // Parses a list of elements - function parseList(kind: ParsingContext, parseElement: () => T): NodeArray { + function parseList(kind: ParsingContext, checkForStrictMode: boolean, parseElement: () => T): NodeArray { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = >[]; result.pos = getNodePos(); + var saveIsInStrictMode = isInStrictMode; while (!isListTerminator(kind)) { if (isListElement(kind, /* inErrorRecovery */ false)) { - result.push(parseElement()); + var element = parseElement(); + result.push(element); + // test elements only if we are not already in strict mode + if (!isInStrictMode && checkForStrictMode) { + if (isPrologueDirective(element)) { + if (isUseStrictPrologueDirective(element)) { + isInStrictMode = true; + checkForStrictMode = false; + } + } + else { + checkForStrictMode = false; + } + } } else { error(parsingContextErrors(kind)); @@ -784,6 +822,7 @@ module ts { nextToken(); } } + isInStrictMode = saveIsInStrictMode; result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; @@ -865,12 +904,13 @@ module ts { return createMissingList(); } - function parseEntityName(): EntityName { + // The allowReservedWords parameter controls whether reserved words are permitted after the first dot + function parseEntityName(allowReservedWords: boolean): EntityName { var entity: EntityName = parseIdentifier(); while (parseOptional(SyntaxKind.DotToken)) { var node = createNode(SyntaxKind.QualifiedName, entity.pos); node.left = entity; - node.right = parseIdentifier(); + node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); entity = finishNode(node); } return entity; @@ -899,7 +939,7 @@ module ts { function parseTypeReference(): TypeReferenceNode { var node = createNode(SyntaxKind.TypeReference); - node.typeName = parseEntityName(); + node.typeName = parseEntityName(/*allowReservedWords*/ false); if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) { node.typeArguments = parseTypeArguments(); } @@ -909,7 +949,7 @@ module ts { function parseTypeQuery(): TypeQueryNode { var node = createNode(SyntaxKind.TypeQuery); parseExpected(SyntaxKind.TypeOfKeyword); - node.exprName = parseEntityName(); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } @@ -968,6 +1008,18 @@ module ts { node.flags |= NodeFlags.Rest; } node.name = parseIdentifier(); + if (node.name.kind === SyntaxKind.Missing && node.flags === 0 && isModifier(token)) { + // in cases like + // 'use strict' + // function foo(static) + // isParameter('static') === true, because of isModifier('static') + // however 'static' is not a legal identifier in a strict mode. + // so result of this function will be ParameterDeclaration (flags = 0, name = missing, type = undefined, initializer = undefined) + // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM) + // to avoid this we'll advance cursor to the next token. + nextToken(); + } + if (parseOptional(SyntaxKind.QuestionToken)) { node.flags |= NodeFlags.QuestionMark; } @@ -1012,8 +1064,16 @@ module ts { for (var i = 0; i < parameterCount; i++) { var parameter = parameters[i]; - - if (parameter.flags & NodeFlags.Rest) { + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionDeclaration or FunctionExpression(13.1) + if (isInStrictMode && isEvalOrArgumentsIdentifier(parameter.name)) { + reportInvalidUseInStrictMode(parameter.name); + return; + } + else if (parameter.flags & NodeFlags.Rest) { if (i !== (parameterCount - 1)) { grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); return; @@ -1170,7 +1230,7 @@ module ts { function parseTypeLiteral(): TypeLiteralNode { var node = createNode(SyntaxKind.TypeLiteral); if (parseExpected(SyntaxKind.OpenBraceToken)) { - node.members = parseList(ParsingContext.TypeMembers, parseTypeMember); + node.members = parseList(ParsingContext.TypeMembers, /*checkForStrictMode*/ false, parseTypeMember); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -1358,8 +1418,13 @@ module ts { // Now see if we might be in cases '2' or '3'. // If the expression was a LHS expression, and we have an assignment operator, then - // we're in '2' or '3'. Consume the assignement and return. + // we're in '2' or '3'. Consume the assignment and return. if (isLeftHandSideExpression(expr) && isAssignmentOperator()) { + if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + reportInvalidUseInStrictMode(expr); + } var operator = token; nextToken(); return makeBinaryExpression(expr, operator, parseAssignmentExpression(noIn)); @@ -1659,6 +1724,19 @@ module ts { var operator = token; nextToken(); var operand = parseUnaryExpression(); + if (isInStrictMode) { + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator + if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(operand)) { + reportInvalidUseInStrictMode(operand); + } + else if (token === SyntaxKind.DeleteKeyword && operand.kind === SyntaxKind.Identifier) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + grammarErrorOnNode(operand, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + } return makeUnaryExpression(SyntaxKind.PrefixOperator, pos, operator, operand); case SyntaxKind.LessThanToken: return parseTypeAssertion(); @@ -1680,6 +1758,12 @@ module ts { Debug.assert(isLeftHandSideExpression(expr)); if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) { + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) { + reportInvalidUseInStrictMode(expr); + } var operator = token; nextToken(); expr = makeUnaryExpression(SyntaxKind.PostfixOperator, expr.pos, operator, expr); @@ -1836,7 +1920,12 @@ module ts { if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken); var body = parseBody(/* ignoreMissingOpenBrace */ false); - node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, node.name, sig, body); + // do not propagate property name as name for function expression + // for scenarios like + // var x = 1; + // var y = { x() { } } + // otherwise this will bring y.x into the scope of x which is incorrect + node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, undefined, sig, body); } else { parseExpected(SyntaxKind.ColonToken); @@ -1861,6 +1950,61 @@ module ts { if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine; node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Preserve); parseExpected(SyntaxKind.CloseBraceToken); + + var seen: Map = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + forEach(node.properties, (p: Declaration) => { + if (p.kind === SyntaxKind.OmittedExpression) { + return; + } + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind: number; + if (p.kind === SyntaxKind.PropertyAssignment) { + currentKind = Property; + } + else if (p.kind === SyntaxKind.GetAccessor) { + currentKind = GetAccessor; + } + else if (p.kind === SyntaxKind.SetAccessor) { + currentKind = SetAccesor; + } + else { + Debug.fail("Unexpected syntax kind:" + SyntaxKind[p.kind]); + } + + if (!hasProperty(seen, p.name.text)) { + seen[p.name.text] = currentKind; + } + else { + var existingKind = seen[p.name.text]; + if (currentKind === Property && existingKind === Property) { + if (isInStrictMode) { + grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + } + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[p.name.text] = currentKind | existingKind; + } + else { + grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + }); return finishNode(node); } @@ -1870,6 +2014,11 @@ module ts { var name = isIdentifier() ? parseIdentifier() : undefined; var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken); var body = parseBody(/* ignoreMissingOpenBrace */ false); + if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) { + // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the + // Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1) + reportInvalidUseInStrictMode(name); + } return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body); } @@ -1896,10 +2045,10 @@ module ts { // STATEMENTS - function parseBlock(ignoreMissingOpenBrace: boolean): Block { + function parseBlock(ignoreMissingOpenBrace: boolean, checkForStrictMode: boolean): Block { var node = createNode(SyntaxKind.Block); if (parseExpected(SyntaxKind.OpenBraceToken) || ignoreMissingOpenBrace) { - node.statements = parseList(ParsingContext.BlockStatements, parseStatement); + node.statements = parseList(ParsingContext.BlockStatements,checkForStrictMode, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -1909,7 +2058,7 @@ module ts { } function parseBody(ignoreMissingOpenBrace: boolean): Block { - var block = parseBlock(ignoreMissingOpenBrace); + var block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true); block.kind = SyntaxKind.FunctionBlock; return block; } @@ -2025,12 +2174,20 @@ module ts { function parseWithStatement(): WithStatement { var node = createNode(SyntaxKind.WithStatement); + var startPos = scanner.getTokenPos(); parseExpected(SyntaxKind.WithKeyword); + var endPos = scanner.getStartPos(); parseExpected(SyntaxKind.OpenParenToken); node.expression = parseExpression(); parseExpected(SyntaxKind.CloseParenToken); node.statement = parseStatement(); - return finishNode(node); + node = finishNode(node); + if (isInStrictMode) { + // Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such + // a context is an + grammarErrorAtPos(startPos, endPos - startPos, Diagnostics.with_statements_are_not_allowed_in_strict_mode) + } + return node; } function parseCaseClause(): CaseOrDefaultClause { @@ -2038,7 +2195,7 @@ module ts { parseExpected(SyntaxKind.CaseKeyword); node.expression = parseExpression(); parseExpected(SyntaxKind.ColonToken); - node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement); + node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement); return finishNode(node); } @@ -2046,7 +2203,7 @@ module ts { var node = createNode(SyntaxKind.DefaultClause); parseExpected(SyntaxKind.DefaultKeyword); parseExpected(SyntaxKind.ColonToken); - node.statements = parseList(ParsingContext.SwitchClauseStatements, parseStatement); + node.statements = parseList(ParsingContext.SwitchClauseStatements, /*checkForStrictMode*/ false, parseStatement); return finishNode(node); } @@ -2061,7 +2218,7 @@ module ts { node.expression = parseExpression(); parseExpected(SyntaxKind.CloseParenToken); parseExpected(SyntaxKind.OpenBraceToken); - node.clauses = parseList(ParsingContext.SwitchClauses, parseCaseOrDefaultClause); + node.clauses = parseList(ParsingContext.SwitchClauses, /*checkForStrictMode*/ false, parseCaseOrDefaultClause); parseExpected(SyntaxKind.CloseBraceToken); // Error on duplicate 'default' clauses. @@ -2106,7 +2263,7 @@ module ts { function parseTokenAndBlock(token: SyntaxKind, kind: SyntaxKind): Block { var pos = getNodePos(); parseExpected(token); - var result = parseBlock(/* ignoreMissingOpenBrace */ false); + var result = parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false); result.kind = kind; result.pos = pos; return result; @@ -2121,7 +2278,7 @@ module ts { var typeAnnotationColonLength = scanner.getTextPos() - typeAnnotationColonStart; var typeAnnotation = parseTypeAnnotation(); parseExpected(SyntaxKind.CloseParenToken); - var result = parseBlock(/* ignoreMissingOpenBrace */ false); + var result = parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false); result.kind = SyntaxKind.CatchBlock; result.pos = pos; result.variable = variable; @@ -2129,6 +2286,11 @@ module ts { if (typeAnnotation) { errorAtPos(typeAnnotationColonStart, typeAnnotationColonLength, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } + if (isInStrictMode && isEvalOrArgumentsIdentifier(variable)) { + // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the + // Catch production is eval or arguments + reportInvalidUseInStrictMode(variable); + } return result; } @@ -2201,7 +2363,7 @@ module ts { function parseStatement(): Statement { switch (token) { case SyntaxKind.OpenBraceToken: - return parseBlock(/* ignoreMissingOpenBrace */ false); + return parseBlock(/* ignoreMissingOpenBrace */ false, /*checkForStrictMode*/ false); case SyntaxKind.VarKeyword: return parseVariableStatement(); case SyntaxKind.FunctionKeyword: @@ -2279,6 +2441,11 @@ module ts { if (inAmbientContext && node.initializer && errorCountBeforeVariableDeclaration === file.syntacticErrors.length) { grammarErrorAtPos(initializerStart, initializerFirstTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } + if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) { + // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code + // and its Identifier is eval or arguments + reportInvalidUseInStrictMode(node.name); + } return finishNode(node); } @@ -2309,6 +2476,11 @@ module ts { node.parameters = sig.parameters; node.type = sig.type; node.body = parseAndCheckFunctionBody(/*isConstructor*/ false); + if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) { + // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the + // Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1) + reportInvalidUseInStrictMode(node.name); + } return finishNode(node); } @@ -2651,7 +2823,7 @@ module ts { } var errorCountBeforeClassBody = file.syntacticErrors.length; if (parseExpected(SyntaxKind.OpenBraceToken)) { - node.members = parseList(ParsingContext.ClassMembers, parseClassMemberDeclaration); + node.members = parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -2751,7 +2923,7 @@ module ts { function parseModuleBody(): Block { var node = createNode(SyntaxKind.ModuleBlock); if (parseExpected(SyntaxKind.OpenBraceToken)) { - node.statements = parseList(ParsingContext.ModuleElements, parseModuleElement); + node.statements = parseList(ParsingContext.ModuleElements, /*checkForStrictMode*/ false, parseModuleElement); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -2815,7 +2987,7 @@ module ts { parseExpected(SyntaxKind.ImportKeyword); node.name = parseIdentifier(); parseExpected(SyntaxKind.EqualsToken); - var entityName = parseEntityName(); + var entityName = parseEntityName(/*allowReservedWords*/ false); if (entityName.kind === SyntaxKind.Identifier && (entityName).text === "require" && parseOptional(SyntaxKind.OpenParenToken)) { node.externalModuleName = parseStringLiteral(); parseExpected(SyntaxKind.CloseParenToken); @@ -3008,7 +3180,7 @@ module ts { var referenceComments = processReferenceComments(); file.referencedFiles = referenceComments.referencedFiles; file.amdDependencies = referenceComments.amdDependencies; - file.statements = parseList(ParsingContext.SourceElements, parseSourceElement); + file.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement); file.externalModuleIndicator = getExternalModuleIndicator(); file.nodeCount = nodeCount; file.identifierCount = identifierCount; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5decadcfe1778..545e6d6031063 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -215,7 +215,9 @@ module ts { FirstReservedWord = BreakKeyword, LastReservedWord = WithKeyword, FirstKeyword = BreakKeyword, - LastKeyword = StringKeyword + LastKeyword = StringKeyword, + FirstFutureReservedWord = ImplementsKeyword, + LastFutureReservedWord = YieldKeyword } export enum NodeFlags { diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index f201851049195..9f0927d076512 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/compiler/ambientWithStatements.ts (14 errors) ==== +==== tests/cases/compiler/ambientWithStatements.ts (15 errors) ==== declare module M { break; ~~~~~ @@ -52,5 +52,7 @@ with (x) { ~~~~ !!! Statements are not allowed in ambient contexts. + ~ +!!! All symbols within a 'with' block will be resolved to 'any'. } } \ No newline at end of file diff --git a/tests/baselines/reference/arrowFunctionContexts.errors.txt b/tests/baselines/reference/arrowFunctionContexts.errors.txt index 35b52144102be..b768abb8575a8 100644 --- a/tests/baselines/reference/arrowFunctionContexts.errors.txt +++ b/tests/baselines/reference/arrowFunctionContexts.errors.txt @@ -1,8 +1,10 @@ -==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (9 errors) ==== +==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (10 errors) ==== // Arrow function used in with statement with (window) { ~~~~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. + ~~~~~~ !!! Cannot find name 'window'. var p = () => this; } @@ -52,10 +54,10 @@ // Arrow function used in with statement with (window) { ~~~~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. + ~~~~~~ !!! Cannot find name 'window'. var p = () => this; - ~~~~ -!!! 'this' cannot be referenced in a module body. } // Arrow function as argument to super call diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index 635de47f40297..24b928c784267 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -103,9 +103,8 @@ var __extends = this.__extends || function (d, b) { __.prototype = b.prototype; d.prototype = new __(); }; -var _this = this; with (window) { - var p = function () { return _this; }; + var p = function () { return this; }; } var Base = (function () { function Base(n) { @@ -137,9 +136,8 @@ var M; })(M || (M = {})); var M2; (function (M2) { - var _this = this; with (window) { - var p = function () { return _this; }; + var p = function () { return this; }; } var Base = (function () { function Base(n) { diff --git a/tests/baselines/reference/assignEveryTypeToAny.js b/tests/baselines/reference/assignEveryTypeToAny.js index f082b5c9b76d5..7f36d13d64c0e 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.js +++ b/tests/baselines/reference/assignEveryTypeToAny.js @@ -90,10 +90,10 @@ var h; x = h; var i; x = i; -x = { f: function f() { +x = { f: function () { return 1; } }; -x = { f: function f(x) { +x = { f: function (x) { return x; } }; function j(a) { diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithCallSignatures2.js index 9cc2cebe65037..b010064aba1ef 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures2.js @@ -66,7 +66,7 @@ t = { f: function (x) { return 1; } }; t = { f: function f() { return 1; } }; -t = { f: function f(x) { +t = { f: function (x) { return ''; } }; a = { f: function () { return 1; } }; diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.js b/tests/baselines/reference/assignmentToObjectAndFunction.js index 07afb88493110..48395b3bdc050 100644 --- a/tests/baselines/reference/assignmentToObjectAndFunction.js +++ b/tests/baselines/reference/assignmentToObjectAndFunction.js @@ -32,7 +32,7 @@ var badFundule: Function = bad; // error //// [assignmentToObjectAndFunction.js] var errObj = { toString: 0 }; var goodObj = { - toString: function toString(x) { + toString: function (x) { return ""; } }; diff --git a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js index 1915a7df3f324..53cb0cc067af1 100644 --- a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js +++ b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js @@ -72,7 +72,7 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x, y) { + foo: function (x, y) { }, a: function foo(x, y) { }, diff --git a/tests/baselines/reference/callSignaturesWithDuplicateParameters.js b/tests/baselines/reference/callSignaturesWithDuplicateParameters.js index 0fe2ea5dac750..1107acc51de91 100644 --- a/tests/baselines/reference/callSignaturesWithDuplicateParameters.js +++ b/tests/baselines/reference/callSignaturesWithDuplicateParameters.js @@ -72,7 +72,7 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x, x) { + foo: function (x, x) { }, a: function foo(x, x) { }, diff --git a/tests/baselines/reference/callSignaturesWithOptionalParameters.js b/tests/baselines/reference/callSignaturesWithOptionalParameters.js index 4627a9abfe29f..6f70965895a84 100644 --- a/tests/baselines/reference/callSignaturesWithOptionalParameters.js +++ b/tests/baselines/reference/callSignaturesWithOptionalParameters.js @@ -89,7 +89,7 @@ a(1); a.foo(); a.foo(1); var b = { - foo: function foo(x) { + foo: function (x) { }, a: function foo(x, y) { }, diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers.js b/tests/baselines/reference/callSignaturesWithParameterInitializers.js index e41cc96ed4882..a00877e92c0ed 100644 --- a/tests/baselines/reference/callSignaturesWithParameterInitializers.js +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers.js @@ -95,7 +95,7 @@ a(1); a.foo(); a.foo(1); var b = { - foo: function foo(x) { + foo: function (x) { if (x === void 0) { x = 1; } }, a: function foo(x, y) { diff --git a/tests/baselines/reference/constructorStaticParamNameErrors.errors.txt b/tests/baselines/reference/constructorStaticParamNameErrors.errors.txt new file mode 100644 index 0000000000000..494c28e89e9f2 --- /dev/null +++ b/tests/baselines/reference/constructorStaticParamNameErrors.errors.txt @@ -0,0 +1,8 @@ +==== tests/cases/compiler/constructorStaticParamNameErrors.ts (1 errors) ==== + 'use strict' + // static as constructor parameter name should give error if 'use strict' + class test { + constructor (static) { } + ~~~~~~ +!!! Identifier expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/constructorStaticParamNameErrors.js b/tests/baselines/reference/constructorStaticParamNameErrors.js deleted file mode 100644 index 0db6b5aa9959d..0000000000000 --- a/tests/baselines/reference/constructorStaticParamNameErrors.js +++ /dev/null @@ -1,14 +0,0 @@ -//// [constructorStaticParamNameErrors.ts] -'use strict' -// static as constructor parameter name should give error if 'use strict' -class test { - constructor (static) { } -} - -//// [constructorStaticParamNameErrors.js] -'use strict'; -var test = (function () { - function test(static) { - } - return test; -})(); diff --git a/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt b/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt index ec1752971c9b2..51e9bae840bf3 100644 --- a/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt +++ b/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (8 errors) ==== +==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (9 errors) ==== var x = { a: 1, b: true, // OK @@ -30,6 +30,8 @@ ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ +!!! An object literal cannot have multiple get/set accessors with the same name. + ~ !!! Duplicate identifier 'a'. }; \ No newline at end of file diff --git a/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt b/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt new file mode 100644 index 0000000000000..e184b7761ea17 --- /dev/null +++ b/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt @@ -0,0 +1,10 @@ +==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (2 errors) ==== + "use strict"; + var x = { + x: 1, + x: 2 + ~ +!!! An object literal cannot have multiple properties with the same name in strict mode. + ~ +!!! Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/tests/baselines/reference/functionExpressionInWithBlock.errors.txt b/tests/baselines/reference/functionExpressionInWithBlock.errors.txt new file mode 100644 index 0000000000000..6a0947e95b2d0 --- /dev/null +++ b/tests/baselines/reference/functionExpressionInWithBlock.errors.txt @@ -0,0 +1,10 @@ +==== tests/cases/compiler/functionExpressionInWithBlock.ts (1 errors) ==== + function x() { + with({}) { + ~~ +!!! All symbols within a 'with' block will be resolved to 'any'. + function f() { + () => this; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/functionExpressionInWithBlock.js b/tests/baselines/reference/functionExpressionInWithBlock.js index 2fae2384313e6..f2353412d5cd7 100644 --- a/tests/baselines/reference/functionExpressionInWithBlock.js +++ b/tests/baselines/reference/functionExpressionInWithBlock.js @@ -11,8 +11,7 @@ function x() { function x() { with ({}) { function f() { - var _this = this; - (function () { return _this; }); + (function () { return this; }); } } } diff --git a/tests/baselines/reference/genericsWithoutTypeParameters1.js b/tests/baselines/reference/genericsWithoutTypeParameters1.js index 293bad11b0a74..c06dfff13d159 100644 --- a/tests/baselines/reference/genericsWithoutTypeParameters1.js +++ b/tests/baselines/reference/genericsWithoutTypeParameters1.js @@ -51,7 +51,7 @@ function foo(x, y) { function foo2(x, y) { } var x = { a: new C() }; -var x2 = { a: { bar: function bar() { +var x2 = { a: { bar: function () { return 1; } } }; var D = (function () { diff --git a/tests/baselines/reference/invalidUndefinedValues.js b/tests/baselines/reference/invalidUndefinedValues.js index b2a308d2cbfac..16ff454d8da30 100644 --- a/tests/baselines/reference/invalidUndefinedValues.js +++ b/tests/baselines/reference/invalidUndefinedValues.js @@ -54,7 +54,7 @@ var M; M.x = 1; })(M || (M = {})); x = M; -x = { f: function f() { +x = { f: function () { } }; function f(a) { x = a; diff --git a/tests/baselines/reference/invalidVoidAssignments.js b/tests/baselines/reference/invalidVoidAssignments.js index 4bce3d903986f..980789cb949d6 100644 --- a/tests/baselines/reference/invalidVoidAssignments.js +++ b/tests/baselines/reference/invalidVoidAssignments.js @@ -59,5 +59,5 @@ var E; })(E || (E = {})); x = E; x = 0 /* A */; -x = { f: function f() { +x = { f: function () { } }; diff --git a/tests/baselines/reference/invalidVoidValues.js b/tests/baselines/reference/invalidVoidValues.js index cc6457a41cb7c..9a626b687bb1d 100644 --- a/tests/baselines/reference/invalidVoidValues.js +++ b/tests/baselines/reference/invalidVoidValues.js @@ -46,7 +46,7 @@ var a; x = a; var b; x = b; -x = { f: function f() { +x = { f: function () { } }; var M; (function (M) { diff --git a/tests/baselines/reference/nameCollisionsInPropertyAssignments.errors.txt b/tests/baselines/reference/nameCollisionsInPropertyAssignments.errors.txt deleted file mode 100644 index 3ad8f5bcfb7ff..0000000000000 --- a/tests/baselines/reference/nameCollisionsInPropertyAssignments.errors.txt +++ /dev/null @@ -1,5 +0,0 @@ -==== tests/cases/compiler/nameCollisionsInPropertyAssignments.ts (1 errors) ==== - var x = 1 - var y = { x() { x++; } }; - ~ -!!! An arithmetic operand must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/nameCollisionsInPropertyAssignments.js b/tests/baselines/reference/nameCollisionsInPropertyAssignments.js index afda3803448c5..3035ab6e6281e 100644 --- a/tests/baselines/reference/nameCollisionsInPropertyAssignments.js +++ b/tests/baselines/reference/nameCollisionsInPropertyAssignments.js @@ -4,6 +4,6 @@ var y = { x() { x++; } }; //// [nameCollisionsInPropertyAssignments.js] var x = 1; -var y = { x: function x() { +var y = { x: function () { x++; } }; diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index a36e532b4be8e..8e1b64f175806 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (41 errors) ==== +==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (59 errors) ==== // Multiple properties with the same name var e1 = { a: 0, a: 0 }; @@ -59,57 +59,93 @@ // Accessor and property with the same name var f1 = { a: 0, get a() { return 0; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f2 = { a: '', get a() { return ''; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f3 = { a: 0, get a() { return ''; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f4 = { a: true, get a() { return false; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f5 = { a: {}, get a() { return {}; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f6 = { a: 0, get 'a'() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier ''a''. var f7 = { 'a': 0, get a() { return 0; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. var f8 = { 'a': 0, get "a"() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier '"a"'. var f9 = { 'a': 0, get 'a'() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier ''a''. var f10 = { "a": 0, get 'a'() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier ''a''. var f11 = { 1.0: 0, get '1'() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier ''1''. var f12 = { 0: 0, get 0() { return 0; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier '0'. var f13 = { 0: 0, get 0() { return 0; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier '0'. var f14 = { 0: 0, get 0x0() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier '0x0'. var f14 = { 0: 0, get 000() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier '000'. var f15 = { "100": 0, get 1e2() { return 0; } }; ~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~ !!! Duplicate identifier '1e2'. var f16 = { 0x20: 0, get 3.2e1() { return 0; } }; ~~~~~ +!!! An object literal cannot have property and accessor with the same name. + ~~~~~ !!! Duplicate identifier '3.2e1'. var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } }; ~ +!!! An object literal cannot have property and accessor with the same name. + ~ !!! Duplicate identifier 'a'. // Get and set accessor with mismatched type annotations diff --git a/tests/baselines/reference/objectLiteralErrors.js b/tests/baselines/reference/objectLiteralErrors.js deleted file mode 100644 index 151cf10a6abfd..0000000000000 --- a/tests/baselines/reference/objectLiteralErrors.js +++ /dev/null @@ -1,135 +0,0 @@ -//// [objectLiteralErrors.ts] - -// Multiple properties with the same name -var e1 = { a: 0, a: 0 }; -var e2 = { a: '', a: '' }; -var e3 = { a: 0, a: '' }; -var e4 = { a: true, a: false }; -var e5 = { a: {}, a: {} }; -var e6 = { a: 0, 'a': 0 }; -var e7 = { 'a': 0, a: 0 }; -var e8 = { 'a': 0, "a": 0 }; -var e9 = { 'a': 0, 'a': 0 }; -var e10 = { "a": 0, 'a': 0 }; -var e11 = { 1.0: 0, '1': 0 }; -var e12 = { 0: 0, 0: 0 }; -var e13 = { 0: 0, 0: 0 }; -var e14 = { 0: 0, 0x0: 0 }; -var e14 = { 0: 0, 000: 0 }; -var e15 = { "100": 0, 1e2: 0 }; -var e16 = { 0x20: 0, 3.2e1: 0 }; -var e17 = { a: 0, b: 1, a: 0 }; - -// Accessor and property with the same name -var f1 = { a: 0, get a() { return 0; } }; -var f2 = { a: '', get a() { return ''; } }; -var f3 = { a: 0, get a() { return ''; } }; -var f4 = { a: true, get a() { return false; } }; -var f5 = { a: {}, get a() { return {}; } }; -var f6 = { a: 0, get 'a'() { return 0; } }; -var f7 = { 'a': 0, get a() { return 0; } }; -var f8 = { 'a': 0, get "a"() { return 0; } }; -var f9 = { 'a': 0, get 'a'() { return 0; } }; -var f10 = { "a": 0, get 'a'() { return 0; } }; -var f11 = { 1.0: 0, get '1'() { return 0; } }; -var f12 = { 0: 0, get 0() { return 0; } }; -var f13 = { 0: 0, get 0() { return 0; } }; -var f14 = { 0: 0, get 0x0() { return 0; } }; -var f14 = { 0: 0, get 000() { return 0; } }; -var f15 = { "100": 0, get 1e2() { return 0; } }; -var f16 = { 0x20: 0, get 3.2e1() { return 0; } }; -var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } }; - -// Get and set accessor with mismatched type annotations -var g1 = { get a(): number { return 4; }, set a(n: string) { } }; -var g2 = { get a() { return 4; }, set a(n: string) { } }; -var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; - - -//// [objectLiteralErrors.js] -var e1 = { a: 0, a: 0 }; -var e2 = { a: '', a: '' }; -var e3 = { a: 0, a: '' }; -var e4 = { a: true, a: false }; -var e5 = { a: {}, a: {} }; -var e6 = { a: 0, 'a': 0 }; -var e7 = { 'a': 0, a: 0 }; -var e8 = { 'a': 0, "a": 0 }; -var e9 = { 'a': 0, 'a': 0 }; -var e10 = { "a": 0, 'a': 0 }; -var e11 = { 1.0: 0, '1': 0 }; -var e12 = { 0: 0, 0: 0 }; -var e13 = { 0: 0, 0: 0 }; -var e14 = { 0: 0, 0x0: 0 }; -var e14 = { 0: 0, 000: 0 }; -var e15 = { "100": 0, 1e2: 0 }; -var e16 = { 0x20: 0, 3.2e1: 0 }; -var e17 = { a: 0, b: 1, a: 0 }; -var f1 = { a: 0, get a() { - return 0; -} }; -var f2 = { a: '', get a() { - return ''; -} }; -var f3 = { a: 0, get a() { - return ''; -} }; -var f4 = { a: true, get a() { - return false; -} }; -var f5 = { a: {}, get a() { - return {}; -} }; -var f6 = { a: 0, get 'a'() { - return 0; -} }; -var f7 = { 'a': 0, get a() { - return 0; -} }; -var f8 = { 'a': 0, get "a"() { - return 0; -} }; -var f9 = { 'a': 0, get 'a'() { - return 0; -} }; -var f10 = { "a": 0, get 'a'() { - return 0; -} }; -var f11 = { 1.0: 0, get '1'() { - return 0; -} }; -var f12 = { 0: 0, get 0() { - return 0; -} }; -var f13 = { 0: 0, get 0() { - return 0; -} }; -var f14 = { 0: 0, get 0x0() { - return 0; -} }; -var f14 = { 0: 0, get 000() { - return 0; -} }; -var f15 = { "100": 0, get 1e2() { - return 0; -} }; -var f16 = { 0x20: 0, get 3.2e1() { - return 0; -} }; -var f17 = { a: 0, get b() { - return 1; -}, get a() { - return 0; -} }; -var g1 = { get a() { - return 4; -}, set a(n) { -} }; -var g2 = { get a() { - return 4; -}, set a(n) { -} }; -var g3 = { get a() { - return undefined; -}, set a(n) { -} }; diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignatures.js b/tests/baselines/reference/objectTypesIdentityWithCallSignatures.js index 733d378cdf0fa..bd45c978d62c3 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignatures.js +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignatures.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.js b/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.js index 4eb44d8daecba..6c02956a1b2ea 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.js +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.js b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.js index 314015046a9f5..e3cdbf7b7dcab 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.js b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.js index 7182e5cd0aff1..6f7ca7aaa2b9f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.js +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.js @@ -143,7 +143,7 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x) { + foo: function (x) { return ''; } }; diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js index b60ab7a68b420..ff213a2f8989c 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js @@ -90,7 +90,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return ''; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js index a49e12a7fb5f1..f3f28d5e9ad81 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js @@ -90,7 +90,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return ''; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures.js index b967ef12e2356..2e1441a4c86ff 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures2.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures2.js index 7bb41dbb4f226..95794735b2cd4 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignatures2.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.js index 3953d2529c6bb..d9fb0242fa712 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.js index b9d3ad18f12ac..278d454cb01c8 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.js @@ -148,7 +148,7 @@ var D = (function () { return D; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.js index 180301492f0df..fcdac6bdfb43b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.js @@ -167,7 +167,7 @@ var D = (function () { return D; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return ''; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType.js index 4ee59c0e33685..79d50124d1e6b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return null; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType2.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType2.js index f8476f53d6877..5d42e66aac14b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByReturnType2.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return null; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts.js index aceea0523ff41..33ac618cb76bd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterCounts.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterNames.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterNames.js index 0c29c37687c15..51191a5d08144 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterNames.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingTypeParameterNames.js @@ -126,7 +126,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x) { +var b = { foo: function (x) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams.js index c7725f4e29dc2..eacf93b7f0052 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams2.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams2.js index 433f734ab4ecb..aeefeaeeb9ebc 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams2.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams3.js b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams3.js index ea044f43302aa..fe8f545653770 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesOptionalParams3.js @@ -128,7 +128,7 @@ var C = (function () { return C; })(); var a; -var b = { foo: function foo(x, y) { +var b = { foo: function (x, y) { return x; } }; function foo1(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js index 69f8510f463ee..c349fe5bd1de1 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js @@ -89,7 +89,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return ''; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js index add492d94f97f..b18a0fa382f1b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js @@ -106,7 +106,7 @@ var D = (function () { return D; })(); var a; -var b = { new: function new(x, y) { +var b = { new: function (x, y) { return ''; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js index 6364251541099..7cd068b7cb54e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js @@ -125,7 +125,7 @@ var D = (function () { return D; })(); var a; -var b = { new: function new(x, y) { +var b = { new: function (x, y) { return ''; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js index 6caa70f01d027..5d68df0d2a2c0 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js @@ -96,7 +96,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return null; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js index de1fbae6e51de..8d35ec4aa39f6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js @@ -92,7 +92,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return null; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js index 8967ad413ad41..5d1bffee03362 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js @@ -86,7 +86,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return x; } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js index 8ba7ad89579dd..2d0653b4e948a 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js @@ -86,7 +86,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x) { +var b = { new: function (x) { return new C(x); } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js index 20deac456adf1..57da54fa5c37f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js @@ -88,7 +88,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x, y) { +var b = { new: function (x, y) { return new C(x, y); } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js index b29859f08e0e7..0eaf30f07c941 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js @@ -88,7 +88,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x, y) { +var b = { new: function (x, y) { return new C(x, y); } }; function foo1b(x) { diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js index ba3ea4cc3b6ff..caecc755fc6bc 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js @@ -88,7 +88,7 @@ var C = (function () { return C; })(); var a; -var b = { new: function new(x, y) { +var b = { new: function (x, y) { return new C(x, y); } }; function foo1b(x) { diff --git a/tests/baselines/reference/parametersWithNoAnnotationAreAny.js b/tests/baselines/reference/parametersWithNoAnnotationAreAny.js index 64452744c96b8..48f8d3e520c68 100644 --- a/tests/baselines/reference/parametersWithNoAnnotationAreAny.js +++ b/tests/baselines/reference/parametersWithNoAnnotationAreAny.js @@ -48,7 +48,7 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x) { + foo: function (x) { return x; }, a: function foo(x) { diff --git a/tests/baselines/reference/parser10.1.1-8gs.errors.txt b/tests/baselines/reference/parser10.1.1-8gs.errors.txt index 4482dd6f1d34b..4ed4b8b26352c 100644 --- a/tests/baselines/reference/parser10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/parser10.1.1-8gs.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parser10.1.1-8gs.ts (4 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -18,4 +18,10 @@ ~~~~~~~~~~~~~ !!! Cannot find name 'NotEarlyError'. var public = 1; + ~~~~~~ +!!! Variable declaration expected. + ~ +!!! Variable declaration expected. + ~ +!!! Variable declaration expected. \ No newline at end of file diff --git a/tests/baselines/reference/parser10.1.1-8gs.js b/tests/baselines/reference/parser10.1.1-8gs.js deleted file mode 100644 index 6c04bffc223b2..0000000000000 --- a/tests/baselines/reference/parser10.1.1-8gs.js +++ /dev/null @@ -1,25 +0,0 @@ -//// [parser10.1.1-8gs.ts] -/// Copyright (c) 2012 Ecma International. All rights reserved. -/// Ecma International makes this code available under the terms and conditions set -/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the -/// "Use Terms"). Any redistribution of this code must retain the above -/// copyright and this notice and otherwise comply with the Use Terms. - -/** - * @path ch10/10.1/10.1.1/10.1.1-8gs.js - * @description Strict Mode - Use Strict Directive Prologue is ''use strict';' which appears twice in the code - * @noStrict - * @negative ^((?!NotEarlyError).)*$ - */ - -"use strict"; -"use strict"; -throw NotEarlyError; -var public = 1; - - -//// [parser10.1.1-8gs.js] -"use strict"; -"use strict"; -throw NotEarlyError; -var public = 1; diff --git a/tests/baselines/reference/parser642331_1.errors.txt b/tests/baselines/reference/parser642331_1.errors.txt new file mode 100644 index 0000000000000..3556849b80617 --- /dev/null +++ b/tests/baselines/reference/parser642331_1.errors.txt @@ -0,0 +1,9 @@ +==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser642331_1.ts (1 errors) ==== + "use strict"; + + class test { + constructor (static) { } + ~~~~~~ +!!! Identifier expected. + } + \ No newline at end of file diff --git a/tests/baselines/reference/parser642331_1.js b/tests/baselines/reference/parser642331_1.js deleted file mode 100644 index 83833ee66123f..0000000000000 --- a/tests/baselines/reference/parser642331_1.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [parser642331_1.ts] -"use strict"; - -class test { - constructor (static) { } -} - - -//// [parser642331_1.js] -"use strict"; -var test = (function () { - function test(static) { - } - return test; -})(); diff --git a/tests/baselines/reference/parserFunctionPropertyAssignment1.js b/tests/baselines/reference/parserFunctionPropertyAssignment1.js index 83d88df46ae7c..9135f98ff6d88 100644 --- a/tests/baselines/reference/parserFunctionPropertyAssignment1.js +++ b/tests/baselines/reference/parserFunctionPropertyAssignment1.js @@ -2,5 +2,5 @@ var v = { foo() { } }; //// [parserFunctionPropertyAssignment1.js] -var v = { foo: function foo() { +var v = { foo: function () { } }; diff --git a/tests/baselines/reference/parserFunctionPropertyAssignment2.js b/tests/baselines/reference/parserFunctionPropertyAssignment2.js index 8975ce36e4c1e..928b01133420a 100644 --- a/tests/baselines/reference/parserFunctionPropertyAssignment2.js +++ b/tests/baselines/reference/parserFunctionPropertyAssignment2.js @@ -2,5 +2,5 @@ var v = { 0() { } }; //// [parserFunctionPropertyAssignment2.js] -var v = { 0: function 0() { +var v = { 0: function () { } }; diff --git a/tests/baselines/reference/parserFunctionPropertyAssignment3.js b/tests/baselines/reference/parserFunctionPropertyAssignment3.js index 15205c0689fe5..03318edc13438 100644 --- a/tests/baselines/reference/parserFunctionPropertyAssignment3.js +++ b/tests/baselines/reference/parserFunctionPropertyAssignment3.js @@ -2,5 +2,5 @@ var v = { "foo"() { } }; //// [parserFunctionPropertyAssignment3.js] -var v = { "foo": function "foo"() { +var v = { "foo": function () { } }; diff --git a/tests/baselines/reference/parserFunctionPropertyAssignment4.js b/tests/baselines/reference/parserFunctionPropertyAssignment4.js index 665241e48f527..8366fb296ff4b 100644 --- a/tests/baselines/reference/parserFunctionPropertyAssignment4.js +++ b/tests/baselines/reference/parserFunctionPropertyAssignment4.js @@ -2,5 +2,5 @@ var v = { 0() { } }; //// [parserFunctionPropertyAssignment4.js] -var v = { 0: function 0() { +var v = { 0: function () { } }; diff --git a/tests/baselines/reference/parserStrictMode10.errors.txt b/tests/baselines/reference/parserStrictMode10.errors.txt new file mode 100644 index 0000000000000..a887f9bdade6e --- /dev/null +++ b/tests/baselines/reference/parserStrictMode10.errors.txt @@ -0,0 +1,6 @@ +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode10.ts (1 errors) ==== + "use strict"; + function f(eval) { + ~~~~ +!!! Invalid use of 'eval' in strict mode. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode10.js b/tests/baselines/reference/parserStrictMode10.js deleted file mode 100644 index 53ec7686d0ed1..0000000000000 --- a/tests/baselines/reference/parserStrictMode10.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserStrictMode10.ts] -"use strict"; -function f(eval) { -} - -//// [parserStrictMode10.js] -"use strict"; -function f(eval) { -} diff --git a/tests/baselines/reference/parserStrictMode11.errors.txt b/tests/baselines/reference/parserStrictMode11.errors.txt new file mode 100644 index 0000000000000..1dc4e0943e456 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode11.errors.txt @@ -0,0 +1,6 @@ +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode11.ts (1 errors) ==== + "use strict"; + var v = function f(eval) { + ~~~~ +!!! Invalid use of 'eval' in strict mode. + }; \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode11.js b/tests/baselines/reference/parserStrictMode11.js deleted file mode 100644 index b34af107f8337..0000000000000 --- a/tests/baselines/reference/parserStrictMode11.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserStrictMode11.ts] -"use strict"; -var v = function f(eval) { -}; - -//// [parserStrictMode11.js] -"use strict"; -var v = function f(eval) { -}; diff --git a/tests/baselines/reference/parserStrictMode12.errors.txt b/tests/baselines/reference/parserStrictMode12.errors.txt index 6a04944298f16..0d50bc4d87b25 100644 --- a/tests/baselines/reference/parserStrictMode12.errors.txt +++ b/tests/baselines/reference/parserStrictMode12.errors.txt @@ -1,5 +1,5 @@ ==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode12.ts (1 errors) ==== "use strict"; var v = { set foo(eval) { } } - ~~~ -!!! Accessors are only available when targeting ECMAScript 5 and higher. \ No newline at end of file + ~~~~ +!!! Invalid use of 'eval' in strict mode. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode13.errors.txt b/tests/baselines/reference/parserStrictMode13.errors.txt new file mode 100644 index 0000000000000..49e1e509ca3bd --- /dev/null +++ b/tests/baselines/reference/parserStrictMode13.errors.txt @@ -0,0 +1,8 @@ +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode13.ts (1 errors) ==== + "use strict"; + try { + } + catch(eval) { + ~~~~ +!!! Invalid use of 'eval' in strict mode. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode13.js b/tests/baselines/reference/parserStrictMode13.js deleted file mode 100644 index c3ace6981f4fa..0000000000000 --- a/tests/baselines/reference/parserStrictMode13.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [parserStrictMode13.ts] -"use strict"; -try { -} -catch(eval) { -} - -//// [parserStrictMode13.js] -"use strict"; -try { -} -catch (eval) { -} diff --git a/tests/baselines/reference/parserStrictMode14.errors.txt b/tests/baselines/reference/parserStrictMode14.errors.txt index 6c5793f2772fa..87439c1a29dac 100644 --- a/tests/baselines/reference/parserStrictMode14.errors.txt +++ b/tests/baselines/reference/parserStrictMode14.errors.txt @@ -1,6 +1,10 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (3 errors) ==== "use strict"; with (a) { + ~~~~ +!!! 'with' statements are not allowed in strict mode. + ~ +!!! All symbols within a 'with' block will be resolved to 'any'. ~ !!! Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode14.js b/tests/baselines/reference/parserStrictMode14.js deleted file mode 100644 index eda7f285f7143..0000000000000 --- a/tests/baselines/reference/parserStrictMode14.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserStrictMode14.ts] -"use strict"; -with (a) { -} - -//// [parserStrictMode14.js] -"use strict"; -with (a) { -} diff --git a/tests/baselines/reference/parserStrictMode2.errors.txt b/tests/baselines/reference/parserStrictMode2.errors.txt index 9ed56baa7b361..98563258c1128 100644 --- a/tests/baselines/reference/parserStrictMode2.errors.txt +++ b/tests/baselines/reference/parserStrictMode2.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts (4 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode2.ts (5 errors) ==== "use strict"; foo1(); ~~~~ @@ -11,4 +11,6 @@ !!! Cannot find name 'foo1'. static(); ~~~~~~ -!!! Cannot find name 'static'. \ No newline at end of file +!!! Declaration or statement expected. + ~ +!!! '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode2.js b/tests/baselines/reference/parserStrictMode2.js deleted file mode 100644 index 79b32ed9a58dd..0000000000000 --- a/tests/baselines/reference/parserStrictMode2.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [parserStrictMode2.ts] -"use strict"; -foo1(); -foo1(); -foo1(); -static(); - -//// [parserStrictMode2.js] -"use strict"; -foo1(); -foo1(); -foo1(); -static(); diff --git a/tests/baselines/reference/parserStrictMode3.errors.txt b/tests/baselines/reference/parserStrictMode3.errors.txt index 9631404b9d565..ab67566a841d2 100644 --- a/tests/baselines/reference/parserStrictMode3.errors.txt +++ b/tests/baselines/reference/parserStrictMode3.errors.txt @@ -1,5 +1,7 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode3.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode3.ts (2 errors) ==== "use strict"; eval = 1; ~~~~ +!!! Invalid use of 'eval' in strict mode. + ~~~~ !!! Invalid left-hand side of assignment expression. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode3.js b/tests/baselines/reference/parserStrictMode3.js deleted file mode 100644 index 166d8905a7a28..0000000000000 --- a/tests/baselines/reference/parserStrictMode3.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [parserStrictMode3.ts] -"use strict"; -eval = 1; - -//// [parserStrictMode3.js] -"use strict"; -eval = 1; diff --git a/tests/baselines/reference/parserStrictMode4.errors.txt b/tests/baselines/reference/parserStrictMode4.errors.txt index 173c86131b45d..e73d99fcaec63 100644 --- a/tests/baselines/reference/parserStrictMode4.errors.txt +++ b/tests/baselines/reference/parserStrictMode4.errors.txt @@ -1,5 +1,7 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode4.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode4.ts (2 errors) ==== "use strict"; arguments = 1; ~~~~~~~~~ +!!! Invalid use of 'arguments' in strict mode. + ~~~~~~~~~ !!! Cannot find name 'arguments'. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode4.js b/tests/baselines/reference/parserStrictMode4.js deleted file mode 100644 index ff1ed9b3a8f3e..0000000000000 --- a/tests/baselines/reference/parserStrictMode4.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [parserStrictMode4.ts] -"use strict"; -arguments = 1; - -//// [parserStrictMode4.js] -"use strict"; -arguments = 1; diff --git a/tests/baselines/reference/parserStrictMode5.errors.txt b/tests/baselines/reference/parserStrictMode5.errors.txt index 1c0cf2da2231c..0cb96d4a4a2a9 100644 --- a/tests/baselines/reference/parserStrictMode5.errors.txt +++ b/tests/baselines/reference/parserStrictMode5.errors.txt @@ -1,5 +1,7 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts (2 errors) ==== "use strict"; eval += 1; + ~~~~ +!!! Invalid use of 'eval' in strict mode. ~~~~~~~~~ !!! Operator '+=' cannot be applied to types '(x: string) => any' and 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode5.js b/tests/baselines/reference/parserStrictMode5.js deleted file mode 100644 index 7e01b0f5d724c..0000000000000 --- a/tests/baselines/reference/parserStrictMode5.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [parserStrictMode5.ts] -"use strict"; -eval += 1; - -//// [parserStrictMode5.js] -"use strict"; -eval += 1; diff --git a/tests/baselines/reference/parserStrictMode6.errors.txt b/tests/baselines/reference/parserStrictMode6.errors.txt index 4dc330e46e818..2d3aef69770c3 100644 --- a/tests/baselines/reference/parserStrictMode6.errors.txt +++ b/tests/baselines/reference/parserStrictMode6.errors.txt @@ -1,5 +1,7 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode6.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode6.ts (2 errors) ==== "use strict"; eval++; ~~~~ +!!! Invalid use of 'eval' in strict mode. + ~~~~ !!! An arithmetic operand must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode6.js b/tests/baselines/reference/parserStrictMode6.js deleted file mode 100644 index 6a4161c3dabc6..0000000000000 --- a/tests/baselines/reference/parserStrictMode6.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [parserStrictMode6.ts] -"use strict"; -eval++; - -//// [parserStrictMode6.js] -"use strict"; -eval++; diff --git a/tests/baselines/reference/parserStrictMode8.errors.txt b/tests/baselines/reference/parserStrictMode8.errors.txt index eebb5d59f7d87..366b405901046 100644 --- a/tests/baselines/reference/parserStrictMode8.errors.txt +++ b/tests/baselines/reference/parserStrictMode8.errors.txt @@ -1,6 +1,8 @@ -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode8.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode8.ts (2 errors) ==== "use strict"; function eval() { ~~~~ +!!! Invalid use of 'eval' in strict mode. + ~~~~ !!! Overload signatures must all be ambient or non-ambient. } \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode8.js b/tests/baselines/reference/parserStrictMode8.js deleted file mode 100644 index 3db5349c4596d..0000000000000 --- a/tests/baselines/reference/parserStrictMode8.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserStrictMode8.ts] -"use strict"; -function eval() { -} - -//// [parserStrictMode8.js] -"use strict"; -function eval() { -} diff --git a/tests/baselines/reference/parserStrictMode9.errors.txt b/tests/baselines/reference/parserStrictMode9.errors.txt new file mode 100644 index 0000000000000..769c69a394321 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode9.errors.txt @@ -0,0 +1,6 @@ +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode9.ts (1 errors) ==== + "use strict"; + var v = function eval() { + ~~~~ +!!! Invalid use of 'eval' in strict mode. + }; \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode9.js b/tests/baselines/reference/parserStrictMode9.js deleted file mode 100644 index a30008634c5a2..0000000000000 --- a/tests/baselines/reference/parserStrictMode9.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserStrictMode9.ts] -"use strict"; -var v = function eval() { -}; - -//// [parserStrictMode9.js] -"use strict"; -var v = function eval() { -}; diff --git a/tests/baselines/reference/parserWithStatement1.d.errors.txt b/tests/baselines/reference/parserWithStatement1.d.errors.txt index 8c6efa440cc3d..b56589d2e0076 100644 --- a/tests/baselines/reference/parserWithStatement1.d.errors.txt +++ b/tests/baselines/reference/parserWithStatement1.d.errors.txt @@ -1,7 +1,9 @@ -==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (3 errors) ==== with (foo) { ~~~~ !!! Statements are not allowed in ambient contexts. ~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. + ~~~ !!! Cannot find name 'foo'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserWithStatement2.errors.txt b/tests/baselines/reference/parserWithStatement2.errors.txt new file mode 100644 index 0000000000000..aa87edfd36c6c --- /dev/null +++ b/tests/baselines/reference/parserWithStatement2.errors.txt @@ -0,0 +1,5 @@ +==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (1 errors) ==== + with (1) + ~ +!!! All symbols within a 'with' block will be resolved to 'any'. + return; \ No newline at end of file diff --git a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt index 53fb3724e149e..e69d84be612e7 100644 --- a/tests/baselines/reference/scanner10.1.1-8gs.errors.txt +++ b/tests/baselines/reference/scanner10.1.1-8gs.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (1 errors) ==== +==== tests/cases/conformance/scanner/ecmascript5/scanner10.1.1-8gs.ts (4 errors) ==== /// Copyright (c) 2012 Ecma International. All rights reserved. /// Ecma International makes this code available under the terms and conditions set /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the @@ -18,4 +18,10 @@ ~~~~~~~~~~~~~ !!! Cannot find name 'NotEarlyError'. var public = 1; + ~~~~~~ +!!! Variable declaration expected. + ~ +!!! Variable declaration expected. + ~ +!!! Variable declaration expected. \ No newline at end of file diff --git a/tests/baselines/reference/scanner10.1.1-8gs.js b/tests/baselines/reference/scanner10.1.1-8gs.js deleted file mode 100644 index 85dada5e79309..0000000000000 --- a/tests/baselines/reference/scanner10.1.1-8gs.js +++ /dev/null @@ -1,25 +0,0 @@ -//// [scanner10.1.1-8gs.ts] -/// Copyright (c) 2012 Ecma International. All rights reserved. -/// Ecma International makes this code available under the terms and conditions set -/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the -/// "Use Terms"). Any redistribution of this code must retain the above -/// copyright and this notice and otherwise comply with the Use Terms. - -/** - * @path ch10/10.1/10.1.1/10.1.1-8gs.js - * @description Strict Mode - Use Strict Directive Prologue is ''use strict';' which appears twice in the code - * @noStrict - * @negative ^((?!NotEarlyError).)*$ - */ - -"use strict"; -"use strict"; -throw NotEarlyError; -var public = 1; - - -//// [scanner10.1.1-8gs.js] -"use strict"; -"use strict"; -throw NotEarlyError; -var public = 1; diff --git a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js index f76df7047eafa..b360b0e45a79e 100644 --- a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js +++ b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js @@ -2,6 +2,6 @@ var x = { n() { } }; //// [sourceMapValidationFunctionPropertyAssignment.js] -var x = { n: function n() { +var x = { n: function () { } }; //# sourceMappingURL=sourceMapValidationFunctionPropertyAssignment.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js.map b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js.map index 10c482a6ba275..74b7201ea8f84 100644 --- a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js.map +++ b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationFunctionPropertyAssignment.js.map] -{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":["n"],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,EAAD,SAAA,CAAC;AAAKA,CAACA,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,EAAD;AAAM,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.sourcemap.txt b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.sourcemap.txt index 00ff4d13586b3..c34558a11a303 100644 --- a/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationFunctionPropertyAssignment.sourcemap.txt @@ -8,7 +8,7 @@ sources: sourceMapValidationFunctionPropertyAssignment.ts emittedFile:tests/cases/compiler/sourceMapValidationFunctionPropertyAssignment.js sourceFile:sourceMapValidationFunctionPropertyAssignment.ts ------------------------------------------------------------------- ->>>var x = { n: function n() { +>>>var x = { n: function () { 1 > 2 >^^^^ 3 > ^ @@ -16,8 +16,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts 5 > ^^ 6 > ^ 7 > ^^ -8 > ^^^^^^^^^ -9 > ^ 1 > 2 >var 3 > x @@ -25,8 +23,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts 5 > { 6 > n 7 > -8 > -9 > n 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0) @@ -34,8 +30,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts 5 >Emitted(1, 11) Source(1, 11) + SourceIndex(0) 6 >Emitted(1, 12) Source(1, 12) + SourceIndex(0) 7 >Emitted(1, 14) Source(1, 11) + SourceIndex(0) -8 >Emitted(1, 23) Source(1, 11) + SourceIndex(0) -9 >Emitted(1, 24) Source(1, 12) + SourceIndex(0) --- >>>} }; 1 > @@ -43,12 +37,12 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts 3 > ^^ 4 > ^ 5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 >() { +1 >n() { 2 >} 3 > } 4 > ; -1 >Emitted(2, 1) Source(1, 17) + SourceIndex(0) name (n) -2 >Emitted(2, 2) Source(1, 18) + SourceIndex(0) name (n) +1 >Emitted(2, 1) Source(1, 17) + SourceIndex(0) +2 >Emitted(2, 2) Source(1, 18) + SourceIndex(0) 3 >Emitted(2, 4) Source(1, 20) + SourceIndex(0) 4 >Emitted(2, 5) Source(1, 21) + SourceIndex(0) --- diff --git a/tests/baselines/reference/sourceMapValidationStatements.errors.txt b/tests/baselines/reference/sourceMapValidationStatements.errors.txt new file mode 100644 index 0000000000000..4ca4140beba79 --- /dev/null +++ b/tests/baselines/reference/sourceMapValidationStatements.errors.txt @@ -0,0 +1,86 @@ +==== tests/cases/compiler/sourceMapValidationStatements.ts (1 errors) ==== + function f() { + var y; + var x = 0; + for (var i = 0; i < 10; i++) { + x += i; + x *= 0; + } + if (x > 17) { + x /= 9; + } else { + x += 10; + x++; + } + var a = [ + 1, + 2, + 3 + ]; + var obj = { + z: 1, + q: "hello" + }; + for (var j in a) { + obj.z = a[j]; + var v = 10; + } + try { + obj.q = "ohhh"; + } catch (e) { + if (obj.z < 10) { + obj.z = 12; + } else { + obj.q = "hmm"; + } + } + try { + throw new Error(); + } catch (e1) { + var b = e1; + } finally { + y = 70; + } + with (obj) { + ~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. + i = 2; + z = 10; + } + switch (obj.z) { + case 0: { + x++; + break; + + } + case 1: { + x--; + break; + + } + default: { + x *= 2; + x = 50; + break; + + } + } + while (x < 10) { + x++; + } + do { + x--; + } while (x > 4) + x = y; + var z = (x == 1) ? x + 1 : x - 1; + (x == 1) ? x + 1 : x - 1; + x === 1; + x = z = 40; + eval("y"); + return; + } + var b = function () { + var x = 10; + x = x + 1; + }; + f(); \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.js b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.js index ec546b4aa6adc..58af9bd2fa4a9 100644 --- a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.js +++ b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures.js @@ -42,7 +42,7 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x) { + foo: function (x) { }, a: function foo(x, y) { }, diff --git a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.js b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.js index 14aa526c55e59..9667537f977e1 100644 --- a/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.js +++ b/tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.js @@ -41,8 +41,8 @@ var C = (function () { })(); var a; var b = { - foo: function foo(x) { + foo: function (x) { }, - foo: function foo(x) { + foo: function (x) { }, }; diff --git a/tests/baselines/reference/superCallsInConstructor.errors.txt b/tests/baselines/reference/superCallsInConstructor.errors.txt index e1d382543ac48..ec6f39b7afe80 100644 --- a/tests/baselines/reference/superCallsInConstructor.errors.txt +++ b/tests/baselines/reference/superCallsInConstructor.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/compiler/superCallsInConstructor.ts (2 errors) ==== +==== tests/cases/compiler/superCallsInConstructor.ts (1 errors) ==== class C { foo() {} bar() {} @@ -11,13 +11,11 @@ class Derived extends Base { constructor() { with(new C()) { + ~~~~~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. foo(); - ~~~ -!!! Cannot find name 'foo'. super(); bar(); - ~~~ -!!! Cannot find name 'bar'. } try {} catch(e) { super(); } diff --git a/tests/baselines/reference/thisInObjectLiterals.js b/tests/baselines/reference/thisInObjectLiterals.js index 20b416700735a..4782f3bccd9a4 100644 --- a/tests/baselines/reference/thisInObjectLiterals.js +++ b/tests/baselines/reference/thisInObjectLiterals.js @@ -29,7 +29,7 @@ var MyClass = (function () { return MyClass; })(); var obj = { - f: function f() { + f: function () { return this.spaaace; } }; diff --git a/tests/baselines/reference/throwInEnclosingStatements.js b/tests/baselines/reference/throwInEnclosingStatements.js index 41da2ec2d07e2..b52926e651ed3 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.js +++ b/tests/baselines/reference/throwInEnclosingStatements.js @@ -88,7 +88,7 @@ var C = (function () { })(); var aa = { id: 12, - biz: function biz() { + biz: function () { throw this; } }; diff --git a/tests/baselines/reference/twoAccessorsWithSameName.errors.txt b/tests/baselines/reference/twoAccessorsWithSameName.errors.txt index e3631f617d997..edac011d718c5 100644 --- a/tests/baselines/reference/twoAccessorsWithSameName.errors.txt +++ b/tests/baselines/reference/twoAccessorsWithSameName.errors.txt @@ -1,4 +1,4 @@ -==== tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts (13 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts (14 errors) ==== class C { get x() { return 1; } ~ @@ -44,6 +44,8 @@ ~ !!! Accessors are only available when targeting ECMAScript 5 and higher. ~ +!!! An object literal cannot have multiple get/set accessors with the same name. + ~ !!! Duplicate identifier 'x'. return 1; } diff --git a/tests/baselines/reference/typeQueryWithReservedWords.js b/tests/baselines/reference/typeQueryWithReservedWords.js new file mode 100644 index 0000000000000..e6e7f86541bbe --- /dev/null +++ b/tests/baselines/reference/typeQueryWithReservedWords.js @@ -0,0 +1,29 @@ +//// [typeQueryWithReservedWords.ts] +class Controller { + create() { + } + delete() { + } + var() { + } +} + +interface IScope { + create: typeof Controller.prototype.create; + delete: typeof Controller.prototype.delete; // Should not error + var: typeof Controller.prototype.var; // Should not error +} + + +//// [typeQueryWithReservedWords.js] +var Controller = (function () { + function Controller() { + } + Controller.prototype.create = function () { + }; + Controller.prototype.delete = function () { + }; + Controller.prototype.var = function () { + }; + return Controller; +})(); diff --git a/tests/baselines/reference/withStatement.errors.txt b/tests/baselines/reference/withStatement.errors.txt index 518426370dd0d..8ffedf2abe6cf 100644 --- a/tests/baselines/reference/withStatement.errors.txt +++ b/tests/baselines/reference/withStatement.errors.txt @@ -1,13 +1,11 @@ -==== tests/cases/compiler/withStatement.ts (2 errors) ==== +==== tests/cases/compiler/withStatement.ts (1 errors) ==== declare var ooo:any; with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) { // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. bing = true; // no error - ~~~~ -!!! Cannot find name 'bing'. bang = true; // no error - ~~~~ -!!! Cannot find name 'bang'. function bar() {} diff --git a/tests/baselines/reference/withStatementErrors.errors.txt b/tests/baselines/reference/withStatementErrors.errors.txt index f6f2eaa74366e..c72d318015944 100644 --- a/tests/baselines/reference/withStatementErrors.errors.txt +++ b/tests/baselines/reference/withStatementErrors.errors.txt @@ -1,13 +1,11 @@ -==== tests/cases/compiler/withStatementErrors.ts (4 errors) ==== +==== tests/cases/compiler/withStatementErrors.ts (3 errors) ==== declare var ooo:any; with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) { // error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! All symbols within a 'with' block will be resolved to 'any'. bing = true; // no error - ~~~~ -!!! Cannot find name 'bing'. bang = true; // no error - ~~~~ -!!! Cannot find name 'bang'. function bar() {} // no error diff --git a/tests/baselines/reference/withStatementNestedScope.errors.txt b/tests/baselines/reference/withStatementNestedScope.errors.txt new file mode 100644 index 0000000000000..141385a1098d4 --- /dev/null +++ b/tests/baselines/reference/withStatementNestedScope.errors.txt @@ -0,0 +1,11 @@ +==== tests/cases/compiler/withStatementNestedScope.ts (1 errors) ==== + var x = 1; + with (x) { + ~ +!!! All symbols within a 'with' block will be resolved to 'any'. + function f(a: number) { + return 1; + } + // should be any + var r = f(1); + } \ No newline at end of file diff --git a/tests/baselines/reference/withStatements.errors.txt b/tests/baselines/reference/withStatements.errors.txt index 15e965da6c2a6..65577ab4c672b 100644 --- a/tests/baselines/reference/withStatements.errors.txt +++ b/tests/baselines/reference/withStatements.errors.txt @@ -1,10 +1,8 @@ -==== tests/cases/conformance/statements/withStatements/withStatements.ts (2 errors) ==== +==== tests/cases/conformance/statements/withStatements/withStatements.ts (1 errors) ==== var x = 12; with (x) { + ~ +!!! All symbols within a 'with' block will be resolved to 'any'. name = 'twelve' - ~~~~ -!!! Cannot find name 'name'. id = 12 - ~~ -!!! Cannot find name 'id'. } \ No newline at end of file diff --git a/tests/cases/compiler/duplicatePropertiesInStrictMode.ts b/tests/cases/compiler/duplicatePropertiesInStrictMode.ts new file mode 100644 index 0000000000000..bea869f93a44e --- /dev/null +++ b/tests/cases/compiler/duplicatePropertiesInStrictMode.ts @@ -0,0 +1,5 @@ +"use strict"; +var x = { + x: 1, + x: 2 +} \ No newline at end of file diff --git a/tests/cases/conformance/types/specifyingTypes/typeQueries/typeQueryWithReservedWords.ts b/tests/cases/conformance/types/specifyingTypes/typeQueries/typeQueryWithReservedWords.ts new file mode 100644 index 0000000000000..5fb9d2233f1e5 --- /dev/null +++ b/tests/cases/conformance/types/specifyingTypes/typeQueries/typeQueryWithReservedWords.ts @@ -0,0 +1,14 @@ +class Controller { + create() { + } + delete() { + } + var() { + } +} + +interface IScope { + create: typeof Controller.prototype.create; + delete: typeof Controller.prototype.delete; // Should not error + var: typeof Controller.prototype.var; // Should not error +}