From f4d28eb6a43557882179dd81b66e17cfac9eda99 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 5 Sep 2024 15:16:02 -0700 Subject: [PATCH] Editorial: add `SameType` AO (#3408) --- spec.html | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/spec.html b/spec.html index e8fa3043cf..7da8622829 100644 --- a/spec.html +++ b/spec.html @@ -5871,6 +5871,30 @@

+ +

+ SameType ( + _x_: an ECMAScript language value, + _y_: an ECMAScript language value, + ): a Boolean +

+
+
description
+
It determines whether or not the two arguments are the same type.
+
+ + 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*. + +
+

SameValue ( @@ -5883,7 +5907,7 @@

It determines whether or not the two arguments are the same value.
- 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_). @@ -5905,7 +5929,7 @@

It determines whether or not the two arguments are the same value (ignoring the difference between *+0*𝔽 and *-0*𝔽).
- 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::sameValueZero(_x_, _y_). 1. Return SameValueNonNumber(_x_, _y_). @@ -5925,7 +5949,7 @@

- 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_). @@ -5985,7 +6009,7 @@

1. NOTE: Because _px_ and _py_ are primitive values, evaluation order is not important. 1. Let _nx_ be ? ToNumeric(_px_). 1. Let _ny_ be ? ToNumeric(_py_). - 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, @@ -6017,7 +6041,7 @@

It provides the semantics for the `==` operator.
- 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*. @@ -6052,7 +6076,7 @@

It provides the semantics for the `===` operator.
- 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_). @@ -20659,7 +20683,7 @@

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_).