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 29, 2024
1 parent 815aa8a commit b606011
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -5871,6 +5871,29 @@ <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 _y_, 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 +5906,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 +5928,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 +5948,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 +6008,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 +6040,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 +6075,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 @@ -20659,7 +20682,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 b606011

Please sign in to comment.