Closed
Description
Per the spec:
SuperProperty: super [ Expression ]
1. Let propertyNameReference be the result of evaluating Expression.
2. Let propertyNameValue be ? GetValue(propertyNameReference).
3. Let propertyKey be ? ToPropertyKey(propertyNameValue).
...
5. Return ? MakeSuperPropertyReference(propertyKey, strict).
Runtime Semantics: MakeSuperPropertyReference(propertyKey, strict)
1. Let env be GetThisEnvironment( ).
...
3. Let actualThis be ? env.GetThisBinding().
...
This differs from regular MemberExpression
:
MemberExpression: MemberExpression [ Expression ]
1. Let baseReference be the result of evaluating MemberExpression.
...
3. Let propertyNameReference be the result of evaluating Expression.
The fact that we evaluate the the inner [ Expression ]
before evaluating the super
feels wrong. I realize super.property
isn't really a MemberExpression
, but it looks just like it. This is observable with super[super(), "prop"]
, allowing me to initialize the this binding (GetThisEnvironment ().BindThisValue(...)
) even after I've referenced it.
Can we move the env.GetThisBinding()
into SuperProperty
's RS: Evaluation
?
As for real-world implementations of super[super(), "prop"]
:
Implemntation | Throws? |
---|---|
Chrome | Yes |
Firefox | No |
Safari | Yes |
Edge | |
Babel | No, but I'm about to change it... |