mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
class fields: add early errors for argument and super
This commit is contained in:
parent
315eca2bbd
commit
2ab51b3a73
src/class-fields
init-err-contains-boolean.caseinit-err-contains-super.case
initializer-error
cls-decl-fields-arrow-fnc.templatecls-decl-fields-comp-name.templatecls-decl-fields-equality.templatecls-decl-fields-literal-name.templatecls-decl-fields-static-comp-name.templatecls-decl-fields-static-literal-name.templatecls-decl-fields-static-string-literal-name.templatecls-decl-fields-string-literal-name.templatecls-decl-fields-ternary.templatecls-decl-fields-typeof.templatecls-expr-fields-arrow-fnc.templatecls-expr-fields-comp-name.templatecls-expr-fields-equality.templatecls-expr-fields-literal-name.templatecls-expr-fields-static-comp-name.templatecls-expr-fields-static-literal-name.templatecls-expr-fields-static-string-literal-name.templatecls-expr-fields-string-literal-name.templatecls-expr-fields-ternary.templatecls-expr-fields-typeof.template
28
src/class-fields/init-err-contains-boolean.case
Normal file
28
src/class-fields/init-err-contains-boolean.case
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Syntax error if `arguments` used in class field
|
||||
info: |
|
||||
Static Semantics: Early Errors
|
||||
|
||||
FieldDefinition:
|
||||
PropertyNameInitializeropt
|
||||
|
||||
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||
|
||||
Static Semantics: ContainsArguments
|
||||
IdentifierReference : Identifier
|
||||
|
||||
1. If the StringValue of Identifier is "arguments", return true.
|
||||
...
|
||||
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||
features: [class-fields]
|
||||
negative:
|
||||
type: SyntaxError
|
||||
phase: early
|
||||
template: initializer-error
|
||||
---*/
|
||||
|
||||
//- initializer
|
||||
arguments
|
21
src/class-fields/init-err-contains-super.case
Normal file
21
src/class-fields/init-err-contains-super.case
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
desc: Syntax error if `super()` used in class field
|
||||
info: |
|
||||
Static Semantics: Early Errors
|
||||
|
||||
FieldDefinition:
|
||||
PropertyNameInitializeropt
|
||||
|
||||
- It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true.
|
||||
features: [class-fields]
|
||||
negative:
|
||||
type: SyntaxError
|
||||
phase: early
|
||||
template: initializer-error
|
||||
---*/
|
||||
|
||||
//- initializer
|
||||
super()
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-arrow-fnc-
|
||||
name: arrow function expression
|
||||
features: [arrow-function]
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
x = () => /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-comp-name-
|
||||
name: computed ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var x = "string";
|
||||
class C {
|
||||
static [x] = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-equality-
|
||||
name: equality expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
x = {} == /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-literal-name-
|
||||
name: literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
x = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-static-comp-name-
|
||||
name: static computed ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var x = "string";
|
||||
class C {
|
||||
static [x] = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-static-literal-
|
||||
name: static literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
static x = /*{ initializer }*/;
|
||||
}
|
14
src/class-fields/initializer-error/cls-decl-fields-static-string-literal-name.template
Normal file
14
src/class-fields/initializer-error/cls-decl-fields-static-string-literal-name.template
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-static-string-literal-name-
|
||||
name: static string literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
static 'x' = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-string-literal-name-
|
||||
name: string literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
'x' = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-ternary-
|
||||
name: ternary expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
x = false ? {} : /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/statements/class/fields-typeof-
|
||||
name: typeof expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
class C {
|
||||
x = typeof /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-arrow-fnc-
|
||||
name: arrow function expression
|
||||
features: [arrow-function]
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
x = () => /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-comp-name-
|
||||
name: computed ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var x = "string";
|
||||
var C = class {
|
||||
[x] = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-equality-
|
||||
name: equality expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
x = {} == /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-literal-name-
|
||||
name: literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
x = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-static-comp-name-
|
||||
name: static computed ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var x = "string";
|
||||
var C = class {
|
||||
static [x] = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-static-literal-
|
||||
name: static literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
static x = /*{ initializer }*/;
|
||||
}
|
14
src/class-fields/initializer-error/cls-expr-fields-static-string-literal-name.template
Normal file
14
src/class-fields/initializer-error/cls-expr-fields-static-string-literal-name.template
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-static-string-literal-name-
|
||||
name: static string literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
static 'x' = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-string-literal-name-
|
||||
name: string literal ClassElementName
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
'x' = /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-ternary-
|
||||
name: ternary expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
x = true ? {} : /*{ initializer }*/;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2017 Valerie Young. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-class-definitions-static-semantics-early-errors
|
||||
path: language/expressions/class/fields-typeof-
|
||||
name: typeof expression
|
||||
---*/
|
||||
|
||||
throw "Test262: This statement should not be evaluated.";
|
||||
|
||||
var C = class {
|
||||
x = typeof /*{ initializer }*/;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user