Skip to content

Commit b6653be

Browse files
caiolimaMs2ger
authored andcommitted
[defer-import-eval] fixing expectation for super property access
1 parent c84c53e commit b6653be

10 files changed

+587
-99
lines changed

src/import-defer/super-property-set-exported.case

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,62 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5-
esid: sec-module-namespace-exotic-objects-set-p-v-receiver
6-
desc: _ [[Set]] exported called as super access
5+
esid: sec-module-namespace-exotic-objects-getownproperty-p
6+
desc: _ [[GetOwnProperty]] called on super access
77
info: |
8-
[[Set]] ( P, V, Receiver )
9-
1. return false.
8+
SuperProperty : super [ Expression ]
9+
1. Let _env_ be GetThisEnvironment().
10+
1. Let _actualThis_ be ? _env_.GetThisBinding().
11+
1. Let _propertyNameReference_ be ? Evaluation of |Expression|.
12+
1. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
13+
1. Let _strict_ be IsStrict(this |SuperProperty|).
14+
1. Return MakeSuperPropertyReference(_actualThis_, _propertyNameValue_, _strict_).
1015

11-
template: ignore
16+
MakeSuperPropertyReference ( _actualThis_, _propertyKey_, _strict_ )
17+
1. Let _env_ be GetThisEnvironment().
18+
1. Assert: _env_.HasSuperBinding() is *true*.
19+
1. Assert: _env_ is a Function Environment Record.
20+
1. Let _baseValue_ be GetSuperBase(_env_).
21+
1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyKey_, [[Strict]]: _strict_, [[ThisValue]]: _actualThis_ }.
22+
23+
PutValue ( _V_, _W_ )
24+
1. If _V_ is not a Reference Record, throw a *ReferenceError* exception.
25+
...
26+
1. If IsPropertyReference(_V_) is *true*, then
27+
1. Let _baseObj_ be ? ToObject(_V_.[[Base]]).
28+
...
29+
1. Let _succeeded_ be ? _baseObj_.[[Set]](_V_.[[ReferencedName]], _W_, GetThisValue(_V_)).
30+
1. If _succeeded_ is *false* and _V_.[[Strict]] is *true*, throw a *TypeError* exception.
31+
1. Return ~unused~.
32+
...
33+
34+
OrdinarySetWithOwnDescriptor ( _O_, _P_, _V_, _Receiver_, _ownDesc_ )
35+
1. If _ownDesc_ is *undefined*, then
36+
1. Let _parent_ be ? _O_.[[GetPrototypeOf]]().
37+
1. If _parent_ is not *null*, return ? _parent_.[[Set]](_P_, _V_, _Receiver_).
38+
1. Set _ownDesc_ to the PropertyDescriptor { [[Value]]: *undefined*, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true* }.
39+
1. If IsDataDescriptor(_ownDesc_) is *true*, then
40+
1. If _ownDesc_.[[Writable]] is *false*, return *false*.
41+
1. If _Receiver_ is not an Object, return *false*.
42+
1. Let _existingDescriptor_ be ? _Receiver_.[[GetOwnProperty]](_P_).
43+
1. If _existingDescriptor_ is *undefined*, then
44+
1. Assert: _Receiver_ does not currently have a property _P_.
45+
1. Return ? CreateDataProperty(_Receiver_, _P_, _V_).
46+
1. If IsAccessorDescriptor(_existingDescriptor_) is *true*, return *false*.
47+
1. If _existingDescriptor_.[[Writable]] is *false*, return *false*.
48+
1. Let _valueDesc_ be the PropertyDescriptor { [[Value]]: _V_ }.
49+
1. Return ? _Receiver_.[[DefineOwnProperty]](_P_, _valueDesc_).
50+
...
51+
52+
template: trigger-on-possible-export
1253
---*/
1354

1455
//- body
1556
class A { constructor() { return ns; } };
1657
class B extends A {
1758
constructor() {
1859
super();
19-
super.exported = 14;
60+
super[key] = 14;
2061
}
2162
};
2263

src/import-defer/super-property-set-not-exported.case

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/super-property-set-exported.case
3+
// - src/import-defer/trigger-on-possible-export/then-exported.template
4+
/*---
5+
description: _ [[GetOwnProperty]] called on super access (of 'then' when it is an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
SuperProperty : super [ Expression ]
24+
1. Let _env_ be GetThisEnvironment().
25+
1. Let _actualThis_ be ? _env_.GetThisBinding().
26+
1. Let _propertyNameReference_ be ? Evaluation of |Expression|.
27+
1. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
28+
1. Let _strict_ be IsStrict(this |SuperProperty|).
29+
1. Return MakeSuperPropertyReference(_actualThis_, _propertyNameValue_, _strict_).
30+
31+
MakeSuperPropertyReference ( _actualThis_, _propertyKey_, _strict_ )
32+
1. Let _env_ be GetThisEnvironment().
33+
1. Assert: _env_.HasSuperBinding() is *true*.
34+
1. Assert: _env_ is a Function Environment Record.
35+
1. Let _baseValue_ be GetSuperBase(_env_).
36+
1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyKey_, [[Strict]]: _strict_, [[ThisValue]]: _actualThis_ }.
37+
38+
PutValue ( _V_, _W_ )
39+
1. If _V_ is not a Reference Record, throw a *ReferenceError* exception.
40+
...
41+
1. If IsPropertyReference(_V_) is *true*, then
42+
1. Let _baseObj_ be ? ToObject(_V_.[[Base]]).
43+
...
44+
1. Let _succeeded_ be ? _baseObj_.[[Set]](_V_.[[ReferencedName]], _W_, GetThisValue(_V_)).
45+
1. If _succeeded_ is *false* and _V_.[[Strict]] is *true*, throw a *TypeError* exception.
46+
1. Return ~unused~.
47+
...
48+
49+
OrdinarySetWithOwnDescriptor ( _O_, _P_, _V_, _Receiver_, _ownDesc_ )
50+
1. If _ownDesc_ is *undefined*, then
51+
1. Let _parent_ be ? _O_.[[GetPrototypeOf]]().
52+
1. If _parent_ is not *null*, return ? _parent_.[[Set]](_P_, _V_, _Receiver_).
53+
1. Set _ownDesc_ to the PropertyDescriptor { [[Value]]: *undefined*, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true* }.
54+
1. If IsDataDescriptor(_ownDesc_) is *true*, then
55+
1. If _ownDesc_.[[Writable]] is *false*, return *false*.
56+
1. If _Receiver_ is not an Object, return *false*.
57+
1. Let _existingDescriptor_ be ? _Receiver_.[[GetOwnProperty]](_P_).
58+
1. If _existingDescriptor_ is *undefined*, then
59+
1. Assert: _Receiver_ does not currently have a property _P_.
60+
1. Return ? CreateDataProperty(_Receiver_, _P_, _V_).
61+
1. If IsAccessorDescriptor(_existingDescriptor_) is *true*, return *false*.
62+
1. If _existingDescriptor_.[[Writable]] is *false*, return *false*.
63+
1. Let _valueDesc_ be the PropertyDescriptor { [[Value]]: _V_ }.
64+
1. Return ? _Receiver_.[[DefineOwnProperty]](_P_, _valueDesc_).
65+
...
66+
67+
---*/
68+
69+
70+
import "./setup_FIXTURE.js";
71+
72+
import defer * as ns from "./dep-then_FIXTURE.js";
73+
74+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
75+
76+
var key = "then";
77+
78+
class A { constructor() { return ns; } };
79+
class B extends A {
80+
constructor() {
81+
super();
82+
super[key] = 14;
83+
}
84+
};
85+
86+
try {
87+
new B();
88+
} catch (_) {}
89+
90+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// This file was procedurally generated from the following sources:
2+
// - src/import-defer/super-property-set-exported.case
3+
// - src/import-defer/trigger-on-possible-export/then-not-exported.template
4+
/*---
5+
description: _ [[GetOwnProperty]] called on super access (of 'then' when it is not an exported name, does not trigger execution)
6+
esid: sec-module-namespace-exotic-objects
7+
features: [import-defer]
8+
flags: [generated, module]
9+
info: |
10+
IsSymbolLikeNamespaceKey ( _P_, _O_ )
11+
1. If _P_ is a Symbol, return *true*.
12+
1. If _ns_.[[Deferred]] is *true* and _P_ is "then", return *true*.
13+
1. Return *false*.
14+
15+
GetModuleExportsList ( _O_ )
16+
1. If _O_.[[Deferred]] is *true*, then
17+
1. Let _m_ be _O_.[[Module]].
18+
1. If _m_ is a Cyclic Module Record, _m_.[[Status]] is not ~evaluated~, and ReadyForSyncExecution(_m_) is *false*, throw a *TypeError* exception.
19+
1. Perform ? EvaluateSync(_m_).
20+
1. Return _O_.[[Exports]].
21+
22+
23+
SuperProperty : super [ Expression ]
24+
1. Let _env_ be GetThisEnvironment().
25+
1. Let _actualThis_ be ? _env_.GetThisBinding().
26+
1. Let _propertyNameReference_ be ? Evaluation of |Expression|.
27+
1. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
28+
1. Let _strict_ be IsStrict(this |SuperProperty|).
29+
1. Return MakeSuperPropertyReference(_actualThis_, _propertyNameValue_, _strict_).
30+
31+
MakeSuperPropertyReference ( _actualThis_, _propertyKey_, _strict_ )
32+
1. Let _env_ be GetThisEnvironment().
33+
1. Assert: _env_.HasSuperBinding() is *true*.
34+
1. Assert: _env_ is a Function Environment Record.
35+
1. Let _baseValue_ be GetSuperBase(_env_).
36+
1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyKey_, [[Strict]]: _strict_, [[ThisValue]]: _actualThis_ }.
37+
38+
PutValue ( _V_, _W_ )
39+
1. If _V_ is not a Reference Record, throw a *ReferenceError* exception.
40+
...
41+
1. If IsPropertyReference(_V_) is *true*, then
42+
1. Let _baseObj_ be ? ToObject(_V_.[[Base]]).
43+
...
44+
1. Let _succeeded_ be ? _baseObj_.[[Set]](_V_.[[ReferencedName]], _W_, GetThisValue(_V_)).
45+
1. If _succeeded_ is *false* and _V_.[[Strict]] is *true*, throw a *TypeError* exception.
46+
1. Return ~unused~.
47+
...
48+
49+
OrdinarySetWithOwnDescriptor ( _O_, _P_, _V_, _Receiver_, _ownDesc_ )
50+
1. If _ownDesc_ is *undefined*, then
51+
1. Let _parent_ be ? _O_.[[GetPrototypeOf]]().
52+
1. If _parent_ is not *null*, return ? _parent_.[[Set]](_P_, _V_, _Receiver_).
53+
1. Set _ownDesc_ to the PropertyDescriptor { [[Value]]: *undefined*, [[Writable]]: *true*, [[Enumerable]]: *true*, [[Configurable]]: *true* }.
54+
1. If IsDataDescriptor(_ownDesc_) is *true*, then
55+
1. If _ownDesc_.[[Writable]] is *false*, return *false*.
56+
1. If _Receiver_ is not an Object, return *false*.
57+
1. Let _existingDescriptor_ be ? _Receiver_.[[GetOwnProperty]](_P_).
58+
1. If _existingDescriptor_ is *undefined*, then
59+
1. Assert: _Receiver_ does not currently have a property _P_.
60+
1. Return ? CreateDataProperty(_Receiver_, _P_, _V_).
61+
1. If IsAccessorDescriptor(_existingDescriptor_) is *true*, return *false*.
62+
1. If _existingDescriptor_.[[Writable]] is *false*, return *false*.
63+
1. Let _valueDesc_ be the PropertyDescriptor { [[Value]]: _V_ }.
64+
1. Return ? _Receiver_.[[DefineOwnProperty]](_P_, _valueDesc_).
65+
...
66+
67+
---*/
68+
69+
70+
import "./setup_FIXTURE.js";
71+
72+
import defer * as ns from "./dep_FIXTURE.js";
73+
74+
assert.sameValue(globalThis.evaluations.length, 0, "import defer does not trigger evaluation");
75+
76+
var key = "then";
77+
78+
class A { constructor() { return ns; } };
79+
class B extends A {
80+
constructor() {
81+
super();
82+
super[key] = 14;
83+
}
84+
};
85+
86+
try {
87+
new B();
88+
} catch (_) {}
89+
90+
assert.sameValue(globalThis.evaluations.length, 0, "It does not trigger evaluation");

test/language/import/import-defer/evaluation-triggers/ignore-super-property-set-exported.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/language/import/import-defer/evaluation-triggers/ignore-super-property-set-not-exported.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)