Move accessor grammar errors to the grammar checker.

This commit is contained in:
Cyrus Najmabadi 2014-11-18 21:29:07 -08:00
parent c42b277ed7
commit 30ba527177
10 changed files with 93 additions and 254 deletions

View file

@ -2693,7 +2693,7 @@ module ts {
var initialToken = token;
if (parseContextualModifier(SyntaxKind.GetKeyword) || parseContextualModifier(SyntaxKind.SetKeyword)) {
var kind = initialToken === SyntaxKind.GetKeyword ? SyntaxKind.GetAccessor : SyntaxKind.SetAccessor;
return parseAndCheckMemberAccessorDeclaration(kind, initialPos, 0);
return parseMemberAccessorDeclaration(kind, initialPos, 0);
}
return parsePropertyAssignment();
}
@ -3520,50 +3520,6 @@ module ts {
}
}
function parseAndCheckMemberAccessorDeclaration(kind: SyntaxKind, pos: number, flags: NodeFlags): MethodDeclaration {
var errorCountBeforeAccessor = file._parserDiagnostics.length;
var accessor = parseMemberAccessorDeclaration(kind, pos, flags);
if (errorCountBeforeAccessor === file._parserDiagnostics.length) {
if (languageVersion < ScriptTarget.ES5) {
grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
}
else if (inAmbientContext) {
grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
}
else if (accessor.typeParameters) {
grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters);
}
else if (kind === SyntaxKind.GetAccessor && accessor.parameters.length) {
grammarErrorOnNode(accessor.name, Diagnostics.A_get_accessor_cannot_have_parameters);
}
else if (kind === SyntaxKind.SetAccessor) {
if (accessor.type) {
grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
}
else if (accessor.parameters.length !== 1) {
grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
}
else {
var parameter = accessor.parameters[0];
if (parameter.flags & NodeFlags.Rest) {
grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_rest_parameter);
}
else if (parameter.flags & NodeFlags.Modifier) {
grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
else if (parameter.flags & NodeFlags.QuestionMark) {
grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
}
else if (parameter.initializer) {
grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
}
}
}
}
return accessor;
}
function parseMemberAccessorDeclaration(kind: SyntaxKind, pos: number, flags: NodeFlags): MethodDeclaration {
var node = <MethodDeclaration>createNode(kind, pos);
node.flags = flags;
@ -3791,10 +3747,10 @@ module ts {
var pos = getNodePos();
var flags = parseAndCheckModifiers(ModifierContext.ClassMembers);
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
return parseAndCheckMemberAccessorDeclaration(SyntaxKind.GetAccessor, pos, flags);
return parseMemberAccessorDeclaration(SyntaxKind.GetAccessor, pos, flags);
}
if (parseContextualModifier(SyntaxKind.SetKeyword)) {
return parseAndCheckMemberAccessorDeclaration(SyntaxKind.SetAccessor, pos, flags);
return parseMemberAccessorDeclaration(SyntaxKind.SetAccessor, pos, flags);
}
if (token === SyntaxKind.ConstructorKeyword) {
return parseConstructorDeclaration(pos, flags);
@ -4229,7 +4185,7 @@ module ts {
else {
// No parser errors were reported. Perform our stricted grammar checks.
file._syntacticDiagnostics = [];
checkGrammar(sourceText, file);
checkGrammar(sourceText, languageVersion, file);
}
file._parserDiagnostics = undefined;
@ -4270,22 +4226,34 @@ module ts {
return file;
}
function checkGrammar(sourceText: string, file: SourceFileInternal) {
function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFileInternal) {
var syntacticDiagnostics = file._syntacticDiagnostics;
// We're automatically in an ambient context if this is a .d.ts file.
var inAmbientContext = fileExtensionIs(file.filename, ".d.ts");
visitNode(file);
function visitNode(node: Node): void {
// First recurse and perform all grammar checks on the children of this node. If any
// children had an grammar error, then skip reporting errors for this node or anything
// higher.
// First recurse and perform all grammar checks on the children of this node.
var savedInAmbientContext = inAmbientContext
if (node.flags & NodeFlags.Ambient) {
inAmbientContext = true;
}
var diagnosticCount = syntacticDiagnostics.length;
forEachChild(node, visitNode);
if (diagnosticCount !== syntacticDiagnostics.length) {
return;
// If any children had an grammar error, then skip reporting errors for this node or
// anything higher.
if (diagnosticCount === syntacticDiagnostics.length) {
checkNode(node);
}
inAmbientContext = savedInAmbientContext;
}
function checkNode(node: Node) {
// No grammar errors on any of our children. Check this node for grammar errors.
switch (node.kind) {
case SyntaxKind.ArrowFunction: return visitArrowFunction(<FunctionExpression>node);
@ -4320,63 +4288,44 @@ module ts {
}
function visitArrowFunction(node: FunctionExpression) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitCallSignature(node: ConstructorDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitConstructor(node: ConstructorDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitConstructorType(node: SignatureDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitConstructSignature(node: FunctionLikeDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitFunctionDeclaration(node: FunctionLikeDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitFunctionExpression(node: FunctionExpression) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitFunctionType(node: SignatureDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitGetAccessor(node: MethodDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters) ||
checkAccessor(node);
}
function visitIndexSignature(node: SignatureDeclaration): void {
if (checkIndexSignatureParameters(node)) {
return;
}
checkIndexSignatureParameters(node);
}
function checkIndexSignatureParameters(node: SignatureDeclaration): boolean {
@ -4413,12 +4362,14 @@ module ts {
}
function visitMethod(node: MethodDeclaration) {
if (checkParameterList(node.parameters)) {
return;
}
checkParameterList(node.parameters);
}
function visitParameter(node: ParameterDeclaration): void {
checkParameterName(node);
}
function checkParameterName(node: ParameterDeclaration): boolean {
// 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).
@ -4426,7 +4377,7 @@ module ts {
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
if (node.flags & NodeFlags.ParsedInStrictMode && isEvalOrArgumentsIdentifier(node.name)) {
reportInvalidUseInStrictMode(node.name);
return;
return true;
}
}
@ -4438,45 +4389,77 @@ module ts {
var parameter = parameters[i];
if (parameter.flags & NodeFlags.Rest) {
if (i !== (parameterCount - 1)) {
grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
return true;
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
}
if (parameter.flags & NodeFlags.QuestionMark) {
grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_be_optional);
return true;
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_be_optional);
}
if (parameter.initializer) {
grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
return true;
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
}
}
else if (parameter.flags & NodeFlags.QuestionMark || parameter.initializer) {
seenOptionalParameter = true;
if (parameter.flags & NodeFlags.QuestionMark && parameter.initializer) {
grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
return true;
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
}
}
else {
if (seenOptionalParameter) {
grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
return true;
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
}
}
}
function visitSetAccessor(node: MethodDeclaration) {
if (checkParameterList(node.parameters)) {
return;
checkParameterList(node.parameters) ||
checkAccessor(node);
}
function checkAccessor(accessor: MethodDeclaration): boolean {
var kind = accessor.kind;
if (languageVersion < ScriptTarget.ES5) {
return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
}
else if (inAmbientContext) {
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
}
else if (accessor.typeParameters) {
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters);
}
else if (kind === SyntaxKind.GetAccessor && accessor.parameters.length) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_get_accessor_cannot_have_parameters);
}
else if (kind === SyntaxKind.SetAccessor) {
if (accessor.type) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
}
else if (accessor.parameters.length !== 1) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
}
else {
var parameter = accessor.parameters[0];
if (parameter.flags & NodeFlags.Rest) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_rest_parameter);
}
else if (parameter.flags & NodeFlags.Modifier) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
else if (parameter.flags & NodeFlags.QuestionMark) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
}
else if (parameter.initializer) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
}
}
}
}
}
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {
var program: Program;
var files: SourceFile[] = [];

View file

@ -1,9 +1,8 @@
tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters.
tests/cases/compiler/complicatedPrivacy.ts(24,38): error TS1005: ';' expected.
tests/cases/compiler/complicatedPrivacy.ts(73,49): error TS2305: Module 'mglo5' has no exported member 'i6'.
==== tests/cases/compiler/complicatedPrivacy.ts (3 errors) ====
==== tests/cases/compiler/complicatedPrivacy.ts (2 errors) ====
module m1 {
export module m2 {
@ -15,8 +14,6 @@ tests/cases/compiler/complicatedPrivacy.ts(73,49): error TS2305: Module 'mglo5'
export class C2 implements m3.i3 {
public get p1(arg) {
~~
!!! error TS1054: A 'get' accessor cannot have parameters.
return new C1();
}

View file

@ -30,7 +30,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error T
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(205,28): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,36): error TS1005: ';' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(219,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(227,13): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(234,14): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS1128: Declaration or statement expected.
@ -95,7 +94,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error T
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'.
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (95 errors) ====
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (94 errors) ====
declare module "fs" {
export class File {
constructor(filename: string);
@ -420,8 +419,6 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error T
~~~~~
!!! error TS2304: Cannot find name 'yield'.
public get Property() { return 0; }
~~~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
public Member() {
return 0;
}

View file

@ -1,9 +1,5 @@
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS1110: Type expected.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS1110: Type expected.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
@ -14,7 +10,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS
tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (14 errors) ====
==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (10 errors) ====
// error to use super calls outside a constructor
class Base {
@ -33,16 +29,12 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
}
get C() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
return 1;
}
set C(v) {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
@ -59,16 +51,12 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
}
static get C() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
return 1;
}
static set C(v) {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors

View file

@ -1,6 +1,3 @@
tests/cases/compiler/duplicateObjectLiteralProperty.ts(14,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/duplicateObjectLiteralProperty.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name.
tests/cases/compiler/duplicateObjectLiteralProperty.ts(2,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/duplicateObjectLiteralProperty.ts(4,5): error TS2300: Duplicate identifier 'a'.
@ -13,7 +10,7 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(15,9): error TS2300: Dupl
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (13 errors) ====
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (10 errors) ====
var x = {
a: 1,
~
@ -41,18 +38,12 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Dupl
var y = {
get a() { return 0; },
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'a'.
set a(v: number) { },
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'a'.
get a() { return 0; }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS1118: An object literal cannot have multiple get/set accessors with the same name.
~
!!! error TS2300: Duplicate identifier 'a'.

View file

@ -1,10 +1,4 @@
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(13,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(17,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(33,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(37,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(66,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(70,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(4,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(9,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(14,9): error TS2335: 'super' can only be referenced in a derived class.
@ -20,7 +14,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error T
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (20 errors) ====
==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ====
//super call in class constructor with no base type
class NoBase {
constructor() {
@ -38,16 +32,12 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
//super call in class accessor (get and set) with no base type
get foo() {
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
return null;
}
set foo(v) {
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
@ -72,16 +62,12 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
//super call in static class accessor (get and set) with no base type
static get q() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
return null;
}
static set q(n) {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
@ -119,16 +105,12 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
//super call in class accessor (get and set) of derived type
get foo() {
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors
return null;
}
set foo(n) {
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super();
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors

View file

@ -23,18 +23,12 @@ tests/cases/compiler/giant.ts(240,24): error TS1111: A constructor implementatio
tests/cases/compiler/giant.ts(243,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(244,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(245,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(246,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(247,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(248,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(249,23): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(250,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(251,32): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(252,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(254,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(255,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(256,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(257,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(258,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(262,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(262,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(267,30): error TS1037: A function implementation cannot be declared in an ambient context.
@ -64,18 +58,12 @@ tests/cases/compiler/giant.ts(498,24): error TS1111: A constructor implementatio
tests/cases/compiler/giant.ts(501,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(502,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(503,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(504,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(505,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(506,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(507,23): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(508,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(509,32): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(510,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(512,21): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(513,31): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(514,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(515,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(516,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(520,22): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(520,25): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(525,30): error TS1037: A function implementation cannot be declared in an ambient context.
@ -85,18 +73,12 @@ tests/cases/compiler/giant.ts(534,20): error TS1111: A constructor implementatio
tests/cases/compiler/giant.ts(537,17): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(538,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(539,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(540,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(541,27): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(542,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(543,19): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(544,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(545,28): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(546,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(548,17): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(549,27): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(550,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(551,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(552,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/giant.ts(556,18): error TS1037: A function implementation cannot be declared in an ambient context.
tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts.
tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context.
@ -257,7 +239,7 @@ tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all
tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required.
==== tests/cases/compiler/giant.ts (257 errors) ====
==== tests/cases/compiler/giant.ts (239 errors) ====
/*
Prefixes
@ -653,8 +635,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
@ -663,8 +643,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
@ -673,8 +651,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
@ -683,8 +659,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
@ -697,8 +671,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
@ -707,8 +679,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
}
export declare module eaM {
@ -1113,8 +1083,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
@ -1123,8 +1091,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
@ -1133,8 +1099,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
@ -1143,8 +1107,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
@ -1157,8 +1119,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
@ -1167,8 +1127,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
}
export declare module eaM {
@ -1215,8 +1173,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'pgF'.
public get pgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'pgF'.
public psF(param:any) { }
~
@ -1225,8 +1181,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'psF'.
public set psF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'psF'.
private rgF() { }
~
@ -1235,8 +1189,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rgF'.
private get rgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rgF'.
private rsF(param:any) { }
~
@ -1245,8 +1197,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'rsF'.
private set rsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'rsF'.
static tV;
static tF() { }
@ -1259,8 +1209,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tsF'.
static set tsF(param:any)
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tsF'.
static tgF() { }
~
@ -1269,8 +1217,6 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all
!!! error TS2300: Duplicate identifier 'tgF'.
static get tgF()
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~
!!! error TS2300: Duplicate identifier 'tgF'.
}
export declare module eaM {

View file

@ -1,4 +1,3 @@
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(13,13): error TS1108: A 'return' statement can only be used within a function body.
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(13,13): error TS1131: Property or signature expected.
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(14,9): error TS1128: Declaration or statement expected.
@ -6,13 +5,11 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending
tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts(11,5): error TS2411: Property 'a' of type '{ toString: () => {}; }' is not assignable to string index type 'Object'.
==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (6 errors) ====
==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClass2.ts (5 errors) ====
class Foo {
x: string;
y() { }
get Z() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return 1;
}
[x: string]: Object;

View file

@ -1,11 +1,7 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(9,21): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(18,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts(24,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonInClass1.ts (1 errors) ====
class a {
//constructor ();
constructor (n: number);
@ -20,26 +16,18 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantSemicolonIn
public pv;
public get d() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return 30;
}
public set d() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
}
public static get p2() {
~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return { x: 30, y: 40 };
}
private static d2() {
}
private static get p3() {
~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return "string";
}
private pv3;

View file

@ -1,14 +1,4 @@
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(7,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(19,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(33,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(2,9): error TS2300: Duplicate identifier 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(3,9): error TS2300: Duplicate identifier 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(7,9): error TS2300: Duplicate identifier 'x'.
@ -17,49 +7,35 @@ tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameN
tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS2300: Duplicate identifier 'x'.
==== tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts (17 errors) ====
==== tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts (7 errors) ====
class C {
get x() { return 1; }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'x'.
get x() { return 1; } // error
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'x'.
}
class D {
set x(v) { }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'x'.
set x(v) { } // error
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'x'.
}
class E {
get x() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return 1;
}
set x(v) { }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
}
var x = {
get x() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS2300: Duplicate identifier 'x'.
return 1;
},
@ -67,8 +43,6 @@ tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameN
// error
get x() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~
!!! error TS1118: An object literal cannot have multiple get/set accessors with the same name.
~
!!! error TS2300: Duplicate identifier 'x'.
@ -78,11 +52,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameN
var y = {
get x() {
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return 1;
},
set x(v) { }
~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
}