Skip to content

Commit

Permalink
Editorial: add SameType AO (tc39#3408)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 28, 2024
1 parent 815aa8a commit 1d5cb78
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -3147,7 +3147,7 @@ <h2>[[GetOwnProperty]] ( _P_ )</h2>
The normal return type is either Property Descriptor or Undefined.
</li>
<li>
If the Type of the return value is Property Descriptor, the return value must be a fully populated Property Descriptor.
If the return value is a Property Descriptor, the return value must be a fully populated Property Descriptor.
</li>
<li>
If _P_ is described as a non-configurable, non-writable own data property, all future calls to [[GetOwnProperty]] ( _P_ ) must return Property Descriptor whose [[Value]] is SameValue as _P_'s [[Value]] attribute.
Expand Down Expand Up @@ -3236,7 +3236,7 @@ <h2>[[OwnPropertyKeys]] ( )</h2>
The returned List must not contain any duplicate entries.
</li>
<li>
The Type of each element of the returned List is either String or Symbol.
Each element of the returned List is a Property Key.
</li>
<li>
The returned List must contain at least the keys of all non-configurable own properties that have previously been observed.
Expand Down Expand Up @@ -5871,6 +5871,30 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-sametype" type="abstract operation">
<h1>
SameType (
_x_: an ECMAScript language value,
_y_: an ECMAScript language value,
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>It determines whether or not the two arguments are the same type.</dd>
</dl>
<emu-alg>
1. If _x_ is *undefined* and _y_ is *undefined*, return *true*.
1. If _x_ is *null* and _y_ is *null*, return *true*.
1. If _x_ is a Boolean and _y_ is a Boolean, return *true*.
1. If _x_ is a Number and _y_ is a Number, return *true*.
1. If _x_ is a BigInt and _y_ is a BigInt, return *true*.
1. If _x_ is a Symbol and _y_ is a Symbol, return *true*.
1. If _x_ is a String and _y_ is a String, return *true*.
1. If _x_ is an Object and _y_ is an Object, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-samevalue" type="abstract operation">
<h1>
SameValue (
Expand All @@ -5883,7 +5907,7 @@ <h1>
<dd>It determines whether or not the two arguments are the same value.</dd>
</dl>
<emu-alg>
1. If Type(_x_) is not Type(_y_), return *false*.
1. If SameType(_x_, _y_) is *false*, return *false*.
1. If _x_ is a Number, then
1. Return Number::sameValue(_x_, _y_).
1. Return SameValueNonNumber(_x_, _y_).
Expand All @@ -5905,7 +5929,7 @@ <h1>
<dd>It determines whether or not the two arguments are the same value (ignoring the difference between *+0*<sub>𝔽</sub> and *-0*<sub>𝔽</sub>).</dd>
</dl>
<emu-alg>
1. If Type(_x_) is not Type(_y_), return *false*.
1. If SameType(_x_, _y_), return *false*.
1. If _x_ is a Number, then
1. Return Number::sameValueZero(_x_, _y_).
1. Return SameValueNonNumber(_x_, _y_).
Expand All @@ -5925,7 +5949,7 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. Assert: Type(_x_) is Type(_y_).
1. Assert: SameType(_x_, _y_) is *true*.
1. If _x_ is either *null* or *undefined*, return *true*.
1. If _x_ is a BigInt, then
1. Return BigInt::equal(_x_, _y_).
Expand Down Expand Up @@ -5985,7 +6009,7 @@ <h1>
1. NOTE: Because _px_ and _py_ are primitive values, evaluation order is not important.
1. Let _nx_ be ? <emu-meta suppress-effects="user-code">ToNumeric(_px_)</emu-meta>.
1. Let _ny_ be ? <emu-meta suppress-effects="user-code">ToNumeric(_py_)</emu-meta>.
1. If Type(_nx_) is Type(_ny_), then
1. If SameType(_nx_, _ny_) is *true*, then
1. If _nx_ is a Number, then
1. Return Number::lessThan(_nx_, _ny_).
1. Else,
Expand Down Expand Up @@ -6017,7 +6041,7 @@ <h1>
<dd>It provides the semantics for the `==` operator.</dd>
</dl>
<emu-alg>
1. If Type(_x_) is Type(_y_), then
1. If SameType(_x_, _y_) is *true*, then
1. Return IsStrictlyEqual(_x_, _y_).
1. If _x_ is *null* and _y_ is *undefined*, return *true*.
1. If _x_ is *undefined* and _y_ is *null*, return *true*.
Expand Down Expand Up @@ -6052,7 +6076,7 @@ <h1>
<dd>It provides the semantics for the `===` operator.</dd>
</dl>
<emu-alg>
1. If Type(_x_) is not Type(_y_), return *false*.
1. If SameType(_x_, _y_) is *false*, return *false*.
1. If _x_ is a Number, then
1. Return Number::equal(_x_, _y_).
1. Return SameValueNonNumber(_x_, _y_).
Expand Down Expand Up @@ -15898,7 +15922,7 @@ <h1>[[OwnPropertyKeys]] ( ): either a normal completion containing a List of pro
The returned List contains no duplicate entries.
</li>
<li>
The Type of each result List element is either String or Symbol.
Each result List element is a Property Key.
</li>
<li>
The result List must contain the keys of all non-configurable own properties of the target object.
Expand Down Expand Up @@ -20659,7 +20683,7 @@ <h1>
1. NOTE: At this point, it must be a numeric operation.
1. Let _lNum_ be ? ToNumeric(_lVal_).
1. Let _rNum_ be ? ToNumeric(_rVal_).
1. If Type(_lNum_) is not Type(_rNum_), throw a *TypeError* exception.
1. If SameType(_lNum_, _rNum_) is *false*, throw a *TypeError* exception.
1. If _lNum_ is a BigInt, then
1. If _opText_ is `**`, return ? BigInt::exponentiate(_lNum_, _rNum_).
1. If _opText_ is `/`, return ? BigInt::divide(_lNum_, _rNum_).
Expand Down

0 comments on commit 1d5cb78

Please sign in to comment.