1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
// This test file tests the following early error:
Static Semantics: Early Errors
ClassElement : FieldDefinition;
It is a Syntax Error if PropName of FieldDefinition is "constructor".
DefineField(receiver, fieldRecord)
...
8. If fieldName is a Private Name,
...
9. Else,
a. ...
b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue).
CreateDataPropertyOrThrow ( O, P, V )
...
3. Let success be ? CreateDataProperty(O, P, V).
4. If success is false, throw a TypeError exception.
...
CreateDataProperty ( O, P, V )
...
3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true,
[[Configurable]]: true }.
4. Return ? O.[[DefineOwnProperty]](P, newDesc).
---*/
var x = "constructor";
class C1 {
[x];
}
var c1 = new C1();
assert.sameValue(c1.hasOwnProperty("constructor"), true);
assert.sameValue(C1.hasOwnProperty("constructor"), false);
reportCompare(0, 0);
|