Debian Codegraph @

js/src/tests/test262/language/expressions/member-expression/computed-reference-null-or-undefined.js

raw
1 // Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-evaluate-property-access-with-expression-key
6 description: When getting the value of o[p], ToObject(o) precedes ToPropertyKey(p).
7 info: |
8 13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue, expression, strict )
9 1. Let _propertyNameReference_ be ? Evaluation of _expression_.
10 2. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
11 ...
12 4. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyNameValue_, [[Strict]]: _strict_, [[ThisValue]]: ~empty~ }.
13
14 6.2.5.5 GetValue ( V )
15 1. If V is not a Reference Record, return V.
16 ...
17 3. If IsPropertyReference(V) is true, then
18 a. Let baseObj be ? ToObject(V.[[Base]]).
19 ...
20 c. If V.[[ReferencedName]] is neither a String nor a Symbol, then
21 i. Let referencedName be ? ToPropertyKey(V.[[ReferencedName]]).
22 ---*/
23
24 assert.throws(TypeError, function() {
25 var base = null;
26 var prop = {
27 toString: function() {
28 throw new Test262Error("property key evaluated");
29 }
30 };
31
32 base[prop];
33 });
34
35 assert.throws(TypeError, function() {
36 var base = undefined;
37 var prop = {
38 toString: function() {
39 throw new Test262Error("property key evaluated");
40 }
41 };
42
43 base[prop];
44 });
45
46 reportCompare(0, 0);