Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Allow [[ReferencedName]] in Reference Records to be a not-yet-resolved property key #3307

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -4163,7 +4163,7 @@ <h1>
<emu-clause id="sec-reference-record-specification-type" oldids="sec-reference-specification-type">
<h1>The Reference Record Specification Type</h1>
<p>The <dfn variants="Reference Records">Reference Record</dfn> type is used to explain the behaviour of such operators as `delete`, `typeof`, the assignment operators, the `super` keyword and other language features. For example, the left-hand operand of an assignment is expected to produce a Reference Record.</p>
<p>A Reference Record is a resolved name or property binding; its fields are defined by <emu-xref href="#table-reference-record-fields"></emu-xref>.</p>
<p>A Reference Record is a resolved name or (possibly not-yet-resolved) property binding; its fields are defined by <emu-xref href="#table-reference-record-fields"></emu-xref>.</p>

<emu-table id="table-reference-record-fields" caption="Reference Record Fields">
<table>
Expand All @@ -4179,8 +4179,8 @@ <h1>The Reference Record Specification Type</h1>
</tr>
<tr>
<td oldids="sec-getreferencedname,ao-getreferencedname">[[ReferencedName]]</td>
michaelficarra marked this conversation as resolved.
Show resolved Hide resolved
<td>a String, a Symbol, or a Private Name</td>
<td>The name of the binding. Always a String if [[Base]] value is an Environment Record.</td>
<td>an ECMAScript language value or a Private Name</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a sentence of the form "May be an ECMAScript language value [...] until yada yada" would be clearer than "May temporarily be [...]".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good; added an Otherwise, to your suggestion to clarify that this just applies to property reference cases.

<td>The name of the binding. Always a String if [[Base]] value is an Environment Record. Otherwise, may be an ECMAScript language value other than a String or a Symbol until ToPropertyKey is performed.</td>
</tr>
<tr>
<td oldids="sec-isstrictreference,ao-isstrictreference">[[Strict]]</td>
Expand Down Expand Up @@ -4265,6 +4265,8 @@ <h1>
1. [id="step-getvalue-toobject"] Let _baseObj_ be ? ToObject(_V_.[[Base]]).
1. If IsPrivateReference(_V_) is *true*, then
1. Return ? PrivateGet(_baseObj_, _V_.[[ReferencedName]]).
Copy link
Member

@michaelficarra michaelficarra Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. If _V_.[[ReferencedName]] is neither a String nor a Symbol, then
1. If IsPropertyKey(_V_.[[ReferencedName]]) is *false*, then

Alternatively, I'm not sure why we have that AO instead of just saying "is a property key", since "property key" is a well-defined term. So we could get rid of that AO (as a separate PR) and then just use that phrasing.

Same below for PutValue, of course.

edit: Also evaluation of delete 🤦‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good; opened #3316.

1. If _V_.[[ReferencedName]] is not a property key, then
1. Set _V_.[[ReferencedName]] to ? ToPropertyKey(_V_.[[ReferencedName]]).
rkirsling marked this conversation as resolved.
Show resolved Hide resolved
1. Return ? <emu-meta effects="user-code">_baseObj_.[[Get]]</emu-meta>(_V_.[[ReferencedName]], GetThisValue(_V_)).
1. Else,
1. Let _base_ be _V_.[[Base]].
Expand Down Expand Up @@ -4296,6 +4298,8 @@ <h1>
1. [id="step-putvalue-toobject"] Let _baseObj_ be ? ToObject(_V_.[[Base]]).
1. If IsPrivateReference(_V_) is *true*, then
1. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
1. If _V_.[[ReferencedName]] is not a property key, then
1. Set _V_.[[ReferencedName]] to ? ToPropertyKey(_V_.[[ReferencedName]]).
1. Let _succeeded_ be ? <emu-meta effects="user-code">_baseObj_.[[Set]]</emu-meta>(_V_.[[ReferencedName]], _W_, GetThisValue(_V_)).
1. If _succeeded_ is *false* and _V_.[[Strict]] is *true*, throw a *TypeError* exception.
1. Return ~unused~.
Expand Down Expand Up @@ -19106,8 +19110,8 @@ <h1>
<emu-alg>
1. Let _propertyNameReference_ be ? Evaluation of _expression_.
1. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
1. Let _propertyKey_ be ? ToPropertyKey(_propertyNameValue_).
1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyKey_, [[Strict]]: _strict_, [[ThisValue]]: ~empty~ }.
1. NOTE: In most cases, ToPropertyKey will be performed on _propertyNameValue_ immediately after this step. However, in the case of `a[b] = c`, it will not be performed until after evaluation of `c`.
1. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyNameValue_, [[Strict]]: _strict_, [[ThisValue]]: ~empty~ }.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -19239,9 +19243,9 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _actualThis_ be ? _env_.GetThisBinding().
1. Let _propertyNameReference_ be ? Evaluation of |Expression|.
1. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
1. Let _propertyKey_ be ? ToPropertyKey(_propertyNameValue_).
1. Let _strict_ be IsStrict(this |SuperProperty|).
1. Return ? MakeSuperPropertyReference(_actualThis_, _propertyKey_, _strict_).
1. NOTE: In most cases, ToPropertyKey will be performed on _propertyNameValue_ immediately after this step. However, in the case of `super[b] = c`, it will not be performed until after evaluation of `c`.
1. Return ? MakeSuperPropertyReference(_actualThis_, _propertyNameValue_, _strict_).
</emu-alg>
<emu-grammar>SuperProperty : `super` `.` IdentifierName</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -19286,7 +19290,7 @@ <h1>GetSuperConstructor ( ): an ECMAScript language value</h1>
<h1>
MakeSuperPropertyReference (
_actualThis_: an ECMAScript language value,
_propertyKey_: a property key,
_propertyKey_: an ECMAScript language value,
_strict_: a Boolean,
): either a normal completion containing a Super Reference Record or a throw completion
</h1>
Expand Down Expand Up @@ -19800,6 +19804,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Assert: IsPrivateReference(_ref_) is *false*.
1. If IsSuperReference(_ref_) is *true*, throw a *ReferenceError* exception.
1. [id="step-delete-operator-toobject"] Let _baseObj_ be ? ToObject(_ref_.[[Base]]).
1. If _ref_.[[ReferencedName]] is not a property key, then
1. Set _ref_.[[ReferencedName]] to ? ToPropertyKey(_ref_.[[ReferencedName]]).
1. Let _deleteStatus_ be ? <emu-meta effects="user-code">_baseObj_.[[Delete]]</emu-meta>(_ref_.[[ReferencedName]]).
1. If _deleteStatus_ is *false* and _ref_.[[Strict]] is *true*, throw a *TypeError* exception.
1. Return _deleteStatus_.
Expand Down Expand Up @@ -20460,7 +20466,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1. If |LeftHandSideExpression| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
1. Let _lref_ be ? Evaluation of |LeftHandSideExpression|.
1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]].
1. Let _lhs_ be the StringValue of |LeftHandSideExpression|.
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lhs_.
1. Else,
1. Let _rref_ be ? Evaluation of |AssignmentExpression|.
1. Let _rval_ be ? GetValue(_rref_).
Expand Down Expand Up @@ -20509,7 +20516,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _lbool_ be ToBoolean(_lval_).
1. If _lbool_ is *false*, return _lval_.
1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]].
1. Let _lhs_ be the StringValue of |LeftHandSideExpression|.
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lhs_.
1. Else,
1. Let _rref_ be ? Evaluation of |AssignmentExpression|.
1. Let _rval_ be ? GetValue(_rref_).
Expand All @@ -20523,7 +20531,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _lbool_ be ToBoolean(_lval_).
1. If _lbool_ is *true*, return _lval_.
1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]].
1. Let _lhs_ be the StringValue of |LeftHandSideExpression|.
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lhs_.
1. Else,
1. Let _rref_ be ? Evaluation of |AssignmentExpression|.
1. Let _rval_ be ? GetValue(_rref_).
Expand All @@ -20536,7 +20545,8 @@ <h1>Runtime Semantics: Evaluation</h1>
1. [id="step-assignmentexpression-evaluation-lgcl-nullish-getvalue"] Let _lval_ be ? GetValue(_lref_).
1. If _lval_ is neither *undefined* nor *null*, return _lval_.
1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]].
1. Let _lhs_ be the StringValue of |LeftHandSideExpression|.
1. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lhs_.
1. Else,
1. Let _rref_ be ? Evaluation of |AssignmentExpression|.
1. Let _rval_ be ? GetValue(_rref_).
Expand Down Expand Up @@ -20903,7 +20913,8 @@ <h1>
1. Set _value_ to _next_.
1. If |Initializer| is present and _value_ is *undefined*, then
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true* and IsIdentifierRef of |DestructuringAssignmentTarget| is *true*, then
1. Let _v_ be ? NamedEvaluation of |Initializer| with argument _lref_.[[ReferencedName]].
1. Let _target_ be the StringValue of |DestructuringAssignmentTarget|.
1. Let _v_ be ? NamedEvaluation of |Initializer| with argument _target_.
1. Else,
1. Let _defaultValue_ be ? Evaluation of |Initializer|.
1. Let _v_ be ? GetValue(_defaultValue_).
Expand Down Expand Up @@ -20951,7 +20962,8 @@ <h1>
1. Let _v_ be ? GetV(_value_, _propertyName_).
1. If |Initializer| is present and _v_ is *undefined*, then
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true* and IsIdentifierRef of |DestructuringAssignmentTarget| is *true*, then
1. Let _rhsValue_ be ? NamedEvaluation of |Initializer| with argument _lref_.[[ReferencedName]].
1. Let _target_ be the StringValue of |DestructuringAssignmentTarget|.
1. Let _rhsValue_ be ? NamedEvaluation of |Initializer| with argument _target_.
1. Else,
1. Let _defaultValue_ be ? Evaluation of |Initializer|.
1. Let _rhsValue_ be ? GetValue(_defaultValue_).
Expand Down
Loading