Debian Codegraph @

js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-this.js

raw
1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-runtime-semantics-classdefinitionevaluation
5 description: >
6 The `this` value of a null-extending class isn't automatically initialized
7 info: |
8 Runtime Semantics: ClassDefinitionEvaluation
9
10 [...]
11 15. If ClassHeritageopt is present, then set F's [[ConstructorKind]] internal slot to "derived".
12 [...]
13
14 12.2.2.1 Runtime Semantics: Evaluation
15 PrimaryExpression : this
16 1. Return ? ResolveThisBinding( ).
17
18 8.3.4 ResolveThisBinding ( )
19 [...]
20 2. Return ? envRec.GetThisBinding().
21
22 8.1.1.3.4 GetThisBinding ( )
23 [...]
24 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError exception.
25 [...]
26 ---*/
27
28 class C extends null {
29 constructor() {
30 // Use an arrow function to access the `this` binding of the class constructor.
31 assert.throws(ReferenceError, () => {
32 this;
33 });
34 }
35 }
36
37 assert.throws(ReferenceError, function() {
38 new C();
39 });
40
41 reportCompare(0, 0);