mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Add tests for "Class Static Init. Blocks" proposal (#2968)
* Add tests for "Class Static Init. Blocks" proposal This proposal is currently at "stage 3" in TC39's standardization process. * fixup! Add tests for "Class Static Init. Blocks" proposal * Correct identifier reference * Update tests for grammar * Update tests for identifiers * Add tests for scope derivation
This commit is contained in:
parent
f1f3a2d542
commit
afe217b318
@ -217,6 +217,10 @@ align-detached-buffer-semantics-with-web-reality
|
|||||||
# https://github.com/tc39/proposal-accessible-object-hasownproperty
|
# https://github.com/tc39/proposal-accessible-object-hasownproperty
|
||||||
Object.hasOwn
|
Object.hasOwn
|
||||||
|
|
||||||
|
# Class static initialization blocks
|
||||||
|
# https://github.com/tc39/proposal-class-static-block
|
||||||
|
class-static-block
|
||||||
|
|
||||||
## Standard language features
|
## Standard language features
|
||||||
#
|
#
|
||||||
# Language features that have been included in a published version of the
|
# Language features that have been included in a published version of the
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is disallowed in the BindingIdentifier position
|
||||||
|
features: [class-static-block]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(await => 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is disallowed in the IdentifierReference position
|
||||||
|
features: [class-static-block]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
((x = await) => 0);
|
||||||
|
}
|
||||||
|
}
|
23
test/language/expressions/class/static-init-await-binding.js
Normal file
23
test/language/expressions/class/static-init-await-binding.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is disallowed as a BindingIdentifier
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(class await {});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as a IdentifierReference in method parameter lists
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
new (class {
|
||||||
|
constructor(x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an IdentifierReference within function expressions
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(function await(await) {});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an IdentifierReference within function expressions
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(function (x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an Identifier within generator function expressions
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(function * await (await) {});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an Identifier within generator function expressions
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(function * (x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The restriction on `await` does not apply to IdentifierName
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({ await: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: IdentifierReference may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "arguments" or "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({ await });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within the body of arrow functions
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => ({ await }));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within the body of accessor methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({set accessor(await) {}});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within the parameter list of generator methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({*method(await) {}});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within the parameter list of methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({method(await) {}});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within accessor methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({
|
||||||
|
set accessor(x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
}
|
||||||
|
}).accessor = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within generator methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({
|
||||||
|
*method(x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
}
|
||||||
|
}).method().next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within methods
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var await = 0;
|
||||||
|
var fromParam, fromBody;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
({
|
||||||
|
method(x = fromParam = await) {
|
||||||
|
fromBody = await;
|
||||||
|
}
|
||||||
|
}).method();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(fromParam, 0, 'from parameter');
|
||||||
|
assert.sameValue(fromBody, 0, 'from body');
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Restriction on `await`
|
||||||
|
info: |
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "arguments" or "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
await;
|
||||||
|
}
|
||||||
|
}
|
27
test/language/statements/break/static-init-without-label.js
Normal file
27
test/language/statements/break/static-init-without-label.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-break-statement
|
||||||
|
description: IterationStatement search does not traverse static initialization block boundaries (no label specified)
|
||||||
|
info: |
|
||||||
|
4.2.1 Static Semantics: Early Errors
|
||||||
|
BreakStatement : break ;
|
||||||
|
|
||||||
|
- It is a Syntax Error if this BreakStatement is not nested, directly or
|
||||||
|
indirectly (but not crossing function or static initialization block
|
||||||
|
boundaries), within an IterationStatement or a SwitchStatement.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
label: while(false) {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
test/language/statements/class/static-init-abrupt.js
Normal file
46
test/language/statements/class/static-init-abrupt.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Returns abrupt completion and halts further class body evaluation
|
||||||
|
info: |
|
||||||
|
34. For each element elementRecord of staticElements in List order, do
|
||||||
|
a. If elementRecord is a ClassFieldDefinition Record, then
|
||||||
|
[...]
|
||||||
|
b. Else,
|
||||||
|
i. Assert: fieldRecord is a ClassStaticBlockDefinition Record.
|
||||||
|
ii. Let status be the result of performing EvaluateStaticBlock(F,
|
||||||
|
elementRecord).
|
||||||
|
d. If status is an abrupt completion, then
|
||||||
|
i. Set the running execution context's LexicalEnvironment to lex.
|
||||||
|
ii. Set the running execution context's PrivateEnvironment to
|
||||||
|
outerPrivateEnvironment.
|
||||||
|
iii. Return Completion(status).
|
||||||
|
features: [class-static-fields-public, class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thrown = new Test262Error();
|
||||||
|
var caught;
|
||||||
|
var sameBlock = false;
|
||||||
|
var subsequentField = false;
|
||||||
|
var subsequentBlock = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
throw thrown;
|
||||||
|
sameBlock = true;
|
||||||
|
}
|
||||||
|
static x = subsequentField = true;
|
||||||
|
static {
|
||||||
|
subsequentBlock = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
caught = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(caught, thrown);
|
||||||
|
assert.sameValue(sameBlock, false, 'same block');
|
||||||
|
assert.sameValue(subsequentField, false, 'subsequent field');
|
||||||
|
assert.sameValue(subsequentBlock, false, 'subsequent block');
|
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The identifier `arguments` is not restricted within function forms
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList
|
||||||
|
is true.
|
||||||
|
includes: [compareArray.js]
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fn, fnParam;
|
||||||
|
var gen, genParam;
|
||||||
|
var asyncFn, asyncFnParam;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(function({test262 = fnParam = arguments}) {
|
||||||
|
fn = arguments;
|
||||||
|
})('function');
|
||||||
|
|
||||||
|
(function * ({test262 = genParam = arguments}) {
|
||||||
|
gen = arguments;
|
||||||
|
})('generator function').next();
|
||||||
|
|
||||||
|
(async function ({test262 = asyncFnParam = arguments}) {
|
||||||
|
asyncFn = arguments;
|
||||||
|
})('async function');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(compareArray(['function'], fn), 'body');
|
||||||
|
assert(compareArray(['function'], fnParam), 'parameter');
|
||||||
|
assert(compareArray(['generator function'], gen), 'body');
|
||||||
|
assert(compareArray(['generator function'], genParam), 'parameter');
|
||||||
|
assert(compareArray(['async function'], asyncFn), 'body');
|
||||||
|
assert(compareArray(['async function'], asyncFnParam), 'parameter');
|
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The identifier `arguments` is not restricted within method forms
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList
|
||||||
|
is true.
|
||||||
|
includes: [compareArray.js]
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var instance;
|
||||||
|
var method, methodParam;
|
||||||
|
var getter;
|
||||||
|
var setter, setterParam;
|
||||||
|
var genMethod, genMethodParam;
|
||||||
|
var asyncMethod, asyncMethodParam;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
instance = new class {
|
||||||
|
method({test262 = methodParam = arguments}) {
|
||||||
|
method = arguments;
|
||||||
|
}
|
||||||
|
get accessor() {
|
||||||
|
getter = arguments;
|
||||||
|
}
|
||||||
|
set accessor({test262 = setterParam = arguments}) {
|
||||||
|
setter = arguments;
|
||||||
|
}
|
||||||
|
*gen({test262 = genMethodParam = arguments}) {
|
||||||
|
genMethod = arguments;
|
||||||
|
}
|
||||||
|
async async({test262 = asyncMethodParam = arguments}) {
|
||||||
|
asyncMethod = arguments;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.method('method');
|
||||||
|
instance.accessor;
|
||||||
|
instance.accessor = 'setter';
|
||||||
|
instance.gen('generator method').next();
|
||||||
|
instance.async('async method');
|
||||||
|
|
||||||
|
assert(compareArray(['method'], method), 'body');
|
||||||
|
assert(compareArray(['method'], methodParam), 'parameter');
|
||||||
|
assert(compareArray([], getter), 'body');
|
||||||
|
assert(compareArray(['setter'], setter), 'body');
|
||||||
|
assert(compareArray(['setter'], setterParam), 'parameter');
|
||||||
|
assert(compareArray(['generator method'], genMethod), 'body');
|
||||||
|
assert(compareArray(['generator method'], genMethodParam), 'parameter');
|
||||||
|
assert(compareArray(['async method'], asyncMethod), 'body');
|
||||||
|
assert(compareArray(['async method'], asyncMethodParam), 'parameter');
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
class await {}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { class await {} });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-operations-on-objects
|
||||||
|
description: The "new.target" value within a static initialization block is undefined
|
||||||
|
info: |
|
||||||
|
2.1.1 EvaluateStaticBlock ( receiver , blockRecord )
|
||||||
|
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: blockRecord is a ClassStaticBlockDefinition Record.
|
||||||
|
3. Perform ? Call(blockRecord.[[Body]], receiver).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var value = null;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
value = new.target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(value, undefined);
|
23
test/language/statements/class/static-init-expr-this.js
Normal file
23
test/language/statements/class/static-init-expr-this.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-operations-on-objects
|
||||||
|
description: The "this" value within a static initialization block is the class
|
||||||
|
info: |
|
||||||
|
2.1.1 EvaluateStaticBlock ( receiver , blockRecord )
|
||||||
|
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: blockRecord is a ClassStaticBlockDefinition Record.
|
||||||
|
3. Perform ? Call(blockRecord.[[Body]], receiver).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var value;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
value = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(value, C);
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot use `arguments` as an identifier
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList
|
||||||
|
is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(class { [argument\u0073]() {} });
|
||||||
|
}
|
||||||
|
}
|
33
test/language/statements/class/static-init-invalid-await.js
Normal file
33
test/language/statements/class/static-init-invalid-await.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions
|
||||||
|
description: The "Await" parsing context does not apply to the block's statement list
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
ClassStaticBlockStatementList :
|
||||||
|
StatementList[~Yield, +Await, ~Return]opt
|
||||||
|
|
||||||
|
## 15.7.1 Static Semantics: Early Errors
|
||||||
|
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
async function f() {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
await 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot declare duplicate labels
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsDuplicateLabels of
|
||||||
|
ClassStaticBlockStatementList with argument « » is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
x: x: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot declare duplicate lexically-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if the LexicallyDeclaredNames of
|
||||||
|
ClassStaticBlockStatementList contains any duplicate entries.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
let x;
|
||||||
|
let x;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot declare a lexically-scoped binding and function-scoped binding with the same name.
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if any element of the LexicallyDeclaredNames of
|
||||||
|
ClassStaticBlockStatementList also occurs in the VarDeclaredNames of
|
||||||
|
ClassStaticBlockStatementList.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
let x;
|
||||||
|
var x;
|
||||||
|
}
|
||||||
|
}
|
27
test/language/statements/class/static-init-invalid-return.js
Normal file
27
test/language/statements/class/static-init-invalid-return.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions
|
||||||
|
description: The "Return" parsing context does not apply to the block's statement list
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
ClassStaticBlockStatementList :
|
||||||
|
StatementList[~Yield, +Await, ~Return]opt
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
function f() {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot contain SuperCall
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
- It is a Syntax Error if HasDirectSuper of ClassStaticBlock is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot reference an undefined `break` target
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsUndefinedBreakTarget of
|
||||||
|
ClassStaticBlockStatementList with argument « » is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
x: while (false) {
|
||||||
|
break y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Block cannot reference an undefined `continue` target
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsUndefinedContinueTarget of
|
||||||
|
ClassStaticBlockStatementList with arguments « » and « » is true.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
x: while (false) {
|
||||||
|
continue y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
test/language/statements/class/static-init-invalid-yield.js
Normal file
27
test/language/statements/class/static-init-invalid-yield.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions
|
||||||
|
description: The "Yield" parsing context does not apply to the block's statement list
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
ClassStaticBlockStatementList :
|
||||||
|
StatementList[~Yield, +Await, ~Return]opt
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
function * g() {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
yield;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Destruction of environment record for variable-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var test262 = 'outer scope';
|
||||||
|
var probe;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
let test262 = 'first block';
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
probe = test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(probe, 'outer scope');
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Derivation of environment record for lexically-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let probe;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
probe = C;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(probe, C);
|
31
test/language/statements/class/static-init-scope-lex-open.js
Normal file
31
test/language/statements/class/static-init-scope-lex-open.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Creation of new environment record for lexically-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
let test262 = 'outer scope';
|
||||||
|
let probe1, probe2;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
let test262 = 'first block';
|
||||||
|
probe1 = test262;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
let test262 = 'second block';
|
||||||
|
probe2 = test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(test262, 'outer scope');
|
||||||
|
assert.sameValue(probe1, 'first block');
|
||||||
|
assert.sameValue(probe2, 'second block');
|
25
test/language/statements/class/static-init-scope-private.js
Normal file
25
test/language/statements/class/static-init-scope-private.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Shares environment record for privately-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-fields-private, class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var probe;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static #test262 = 'private';
|
||||||
|
|
||||||
|
static {
|
||||||
|
probe = C.#test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(probe, 'private');
|
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Destruction of environment record for variable-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var test262 = 'outer scope';
|
||||||
|
var probe;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
var test262 = 'first block';
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
probe = test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(probe, 'outer scope');
|
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Derivation of environment record for variable-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var test262 = 'outer scope';
|
||||||
|
var probe;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
probe = test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(probe, 'outer scope');
|
31
test/language/statements/class/static-init-scope-var-open.js
Normal file
31
test/language/statements/class/static-init-scope-var-open.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: Creation of new environment record for variable-scoped bindings
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
1. Let lex be the running execution context's LexicalEnvironment.
|
||||||
|
2. Let privateScope be the running execution context's PrivateEnvironment.
|
||||||
|
3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var test262 = 'outer scope';
|
||||||
|
var probe1, probe2;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
var test262 = 'first block';
|
||||||
|
probe1 = test262;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
var test262 = 'second block';
|
||||||
|
probe2 = test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(test262, 'outer scope');
|
||||||
|
assert.sameValue(probe1, 'first block');
|
||||||
|
assert.sameValue(probe2, 'second block');
|
38
test/language/statements/class/static-init-sequence.js
Normal file
38
test/language/statements/class/static-init-sequence.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classelementevaluation
|
||||||
|
description: Static blocks are evaluated in the order they appear in the source text, interleaved with static fields
|
||||||
|
info: |
|
||||||
|
5.1.14 Runtime Semantics: ClassDefinitionEvaluation
|
||||||
|
|
||||||
|
[...]
|
||||||
|
34. For each element elementRecord of staticElements in List order, do
|
||||||
|
a. If elementRecord is a ClassFieldDefinition Record, then
|
||||||
|
i. Let status be the result of performing DefineField(F,
|
||||||
|
elementRecord).
|
||||||
|
b. Else,
|
||||||
|
i. Assert: fieldRecord is a ClassStaticBlockDefinition Record.
|
||||||
|
ii. Let status be the result of performing EvaluateStaticBlock(F,
|
||||||
|
elementRecord).
|
||||||
|
[...]
|
||||||
|
features: [class-static-fields-public, class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var sequence = [];
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static x = sequence.push('first field');
|
||||||
|
static {
|
||||||
|
sequence.push('first block');
|
||||||
|
}
|
||||||
|
static x = sequence.push('second field');
|
||||||
|
static {
|
||||||
|
sequence.push('second block');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(sequence[0], 'first field');
|
||||||
|
assert.sameValue(sequence[1], 'first block');
|
||||||
|
assert.sameValue(sequence[2], 'second field');
|
||||||
|
assert.sameValue(sequence[3], 'second block');
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions
|
||||||
|
description: The block's statement list is optional
|
||||||
|
info: |
|
||||||
|
Syntax
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
ClassStaticBlockStatementList :
|
||||||
|
StatementList[~Yield, +Await, ~Return]opt
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {}
|
||||||
|
}
|
24
test/language/statements/class/static-init-super-property.js
Normal file
24
test/language/statements/class/static-init-super-property.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-runtime-semantics-classstaticblockdefinitionevaluation
|
||||||
|
description: The home object for a class static initialization block is the parent class
|
||||||
|
info: |
|
||||||
|
ClassStaticBlock : static { ClassStaticBlockBody }
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. Perform MakeMethod(body, homeObject).
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function Parent() {}
|
||||||
|
Parent.test262 = 'test262';
|
||||||
|
var value;
|
||||||
|
|
||||||
|
class C extends Parent {
|
||||||
|
static {
|
||||||
|
value = super.test262;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(value, 'test262');
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
const await = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { const await = 0; });
|
||||||
|
}
|
||||||
|
}
|
28
test/language/statements/continue/static-init-with-label.js
Normal file
28
test/language/statements/continue/static-init-with-label.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-continue-statement
|
||||||
|
description: IterationStatement search does not traverse static initialization block boundaries (label specified)
|
||||||
|
info: |
|
||||||
|
4.1.1 Static Semantics: Early Errors
|
||||||
|
ContinueStatement : continue ;
|
||||||
|
ContinueStatement : continue LabelIdentifier ;
|
||||||
|
|
||||||
|
- It is a Syntax Error if this ContinueStatement is not nested, directly or
|
||||||
|
indirectly (but not crossing function or static initialization block
|
||||||
|
boundaries), within an IterationStatement.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
label: while(false) {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
continue label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-continue-statement
|
||||||
|
description: IterationStatement search does not traverse static initialization block boundaries (no label specified)
|
||||||
|
info: |
|
||||||
|
4.1.1 Static Semantics: Early Errors
|
||||||
|
ContinueStatement : continue ;
|
||||||
|
ContinueStatement : continue LabelIdentifier ;
|
||||||
|
|
||||||
|
- It is a Syntax Error if this ContinueStatement is not nested, directly or
|
||||||
|
indirectly (but not crossing function or static initialization block
|
||||||
|
boundaries), within an IterationStatement.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
label: while(false) {
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
function await() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { function await() {} });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: Restriction on `await`
|
||||||
|
info: |
|
||||||
|
LabelIdentifier : Identifier
|
||||||
|
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
await: 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
let await;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { let await; });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
try {} catch (await) {}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { try {} catch (await) {} });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
var [await] = [];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { var [await] = []; });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
var {await} = {};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { var {await} = {}; });
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: BindingIdentifier may not be `await` within class static blocks
|
||||||
|
info: |
|
||||||
|
BindingIdentifier : Identifier
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if the code matched by this production is nested,
|
||||||
|
directly or indirectly (but not crossing function or static initialization
|
||||||
|
block boundaries), within a ClassStaticBlock and the StringValue of
|
||||||
|
Identifier is "await".
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
var await;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
description: The `await` keyword is interpreted as an identifier within arrow function bodies
|
||||||
|
info: |
|
||||||
|
ClassStaticBlockBody : ClassStaticBlockStatementList
|
||||||
|
|
||||||
|
[...]
|
||||||
|
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true.
|
||||||
|
features: [class-static-block]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static {
|
||||||
|
(() => { var await; });
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user