From a4c349abe95237d31fb1158fd2d79711db245882 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 1/9] Editorial: Move fallible parseInt steps to the beginning --- spec.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec.html b/spec.html index acdd9d74e0..79e9edd49c 100644 --- a/spec.html +++ b/spec.html @@ -30094,17 +30094,17 @@

parseInt ( _string_, _radix_ )

It performs the following steps when called:

1. Let _inputString_ be ? ToString(_string_). - 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). - 1. Let _sign_ be 1. - 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is the code unit 0x002D (HYPHEN-MINUS), set _sign_ to -1. - 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is either the code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS), set _trimmedString_ to the substring of _trimmedString_ from index 1. - 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). 1. Let _stripPrefix_ be *true*. + 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). 1. If _radixMV_ ≠ 0, then 1. If _radixMV_ < 2 or _radixMV_ > 36, return *NaN*. 1. If _radixMV_ ≠ 16, set _stripPrefix_ to *false*. 1. Else, 1. Set _radixMV_ to 10. + 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). + 1. Let _sign_ be 1. + 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is the code unit 0x002D (HYPHEN-MINUS), set _sign_ to -1. + 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is either the code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS), set _trimmedString_ to the substring of _trimmedString_ from index 1. 1. If _stripPrefix_ is *true*, then 1. If the length of _trimmedString_ ≥ 2 and the first two code units of _trimmedString_ are either *"0x"* or *"0X"*, then 1. Set _trimmedString_ to the substring of _trimmedString_ from index 2. From dff015fc16014c48820aa7728d9e8c2b7eb2120a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 2/9] Editorial: Fix use of substring in parseInt --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 79e9edd49c..d0156f39a9 100644 --- a/spec.html +++ b/spec.html @@ -30104,10 +30104,10 @@

parseInt ( _string_, _radix_ )

1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). 1. Let _sign_ be 1. 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is the code unit 0x002D (HYPHEN-MINUS), set _sign_ to -1. - 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is either the code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS), set _trimmedString_ to the substring of _trimmedString_ from index 1. + 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is either the code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS), set _trimmedString_ to the substring of _trimmedString_ from 1. 1. If _stripPrefix_ is *true*, then - 1. If the length of _trimmedString_ ≥ 2 and the first two code units of _trimmedString_ are either *"0x"* or *"0X"*, then - 1. Set _trimmedString_ to the substring of _trimmedString_ from index 2. + 1. If the length of _trimmedString_ ≥ 2 and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then + 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. 1. Set _radixMV_ to 16. 1. If _trimmedString_ contains a code unit that is not a radix-_radixMV_ digit, let _end_ be the index within _trimmedString_ of the first such code unit; else let _end_ be the length of _trimmedString_. 1. Let _numberString_ be the substring of _trimmedString_ from 0 to _end_. From 8312298a1edc0c683dd186da0e7dec7f10293364 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 3/9] Editorial: Separate `-`/`+` handling in parseInt --- spec.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index d0156f39a9..cb6d681c9c 100644 --- a/spec.html +++ b/spec.html @@ -30102,9 +30102,13 @@

parseInt ( _string_, _radix_ )

1. Else, 1. Set _radixMV_ to 10. 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). + 1. If _trimmedString_ is the empty String, return *NaN*. 1. Let _sign_ be 1. - 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is the code unit 0x002D (HYPHEN-MINUS), set _sign_ to -1. - 1. If _trimmedString_ is not empty and the first code unit of _trimmedString_ is either the code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS), set _trimmedString_ to the substring of _trimmedString_ from 1. + 1. If the first code unit of _trimmedString_ is the code unit 0x002D (HYPHEN-MINUS), then + 1. Set _sign_ to -1. + 1. Set _trimmedString_ to the substring of _trimmedString_ from 1. + 1. Else if the first code unit of _trimmedString_ is the code unit 0x002B (PLUS SIGN), then + 1. Set _trimmedString_ to the substring of _trimmedString_ from 1. 1. If _stripPrefix_ is *true*, then 1. If the length of _trimmedString_ ≥ 2 and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. From 229f05ddb35dd69b772099a6cb01ae8bae1d0b96 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 4/9] Editorial: Rename the hex-specific _stripPrefix_ alias in parseInt --- spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index cb6d681c9c..3622c70358 100644 --- a/spec.html +++ b/spec.html @@ -30094,11 +30094,11 @@

parseInt ( _string_, _radix_ )

It performs the following steps when called:

1. Let _inputString_ be ? ToString(_string_). - 1. Let _stripPrefix_ be *true*. + 1. Let _stripHexPrefix_ be *true*. 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). 1. If _radixMV_ ≠ 0, then 1. If _radixMV_ < 2 or _radixMV_ > 36, return *NaN*. - 1. If _radixMV_ ≠ 16, set _stripPrefix_ to *false*. + 1. If _radixMV_ ≠ 16, set _stripHexPrefix_ to *false*. 1. Else, 1. Set _radixMV_ to 10. 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). @@ -30109,7 +30109,7 @@

parseInt ( _string_, _radix_ )

1. Set _trimmedString_ to the substring of _trimmedString_ from 1. 1. Else if the first code unit of _trimmedString_ is the code unit 0x002B (PLUS SIGN), then 1. Set _trimmedString_ to the substring of _trimmedString_ from 1. - 1. If _stripPrefix_ is *true*, then + 1. If _stripHexPrefix_ is *true*, then 1. If the length of _trimmedString_ ≥ 2 and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. 1. Set _radixMV_ to 16. From be74371c4691d60e9653ad827a0912e5f46e836b Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 5/9] Editorial: Reduce hex-specific nesting depth in parseInt --- spec.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index 3622c70358..df9011c074 100644 --- a/spec.html +++ b/spec.html @@ -30109,10 +30109,9 @@

parseInt ( _string_, _radix_ )

1. Set _trimmedString_ to the substring of _trimmedString_ from 1. 1. Else if the first code unit of _trimmedString_ is the code unit 0x002B (PLUS SIGN), then 1. Set _trimmedString_ to the substring of _trimmedString_ from 1. - 1. If _stripHexPrefix_ is *true*, then - 1. If the length of _trimmedString_ ≥ 2 and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then - 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. - 1. Set _radixMV_ to 16. + 1. If _stripHexPrefix_ is *true*, the length of _trimmedString_ ≥ 2, and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then + 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. + 1. Set _radixMV_ to 16. 1. If _trimmedString_ contains a code unit that is not a radix-_radixMV_ digit, let _end_ be the index within _trimmedString_ of the first such code unit; else let _end_ be the length of _trimmedString_. 1. Let _numberString_ be the substring of _trimmedString_ from 0 to _end_. 1. If _numberString_ is empty, return *NaN*. From c8ee84f5d685fac0046b50af339206f15ebe6034 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 6/9] Editorial: Simplify the final return of parseInt --- spec.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec.html b/spec.html index df9011c074..1a27693ad8 100644 --- a/spec.html +++ b/spec.html @@ -30116,9 +30116,7 @@

parseInt ( _string_, _radix_ )

1. Let _numberString_ be the substring of _trimmedString_ from 0 to _end_. 1. If _numberString_ is empty, return *NaN*. 1. Let _mathInt_ be the integer value that is represented by _numberString_ in radix-_radixMV_ notation, using the letters A through Z and a through z for digits with values 10 through 35. (However, if _radixMV_ = 10 and _numberString_ contains more than 20 significant digits, every significant digit after the 20th may be replaced by a 0 digit, at the option of the implementation; and if _radixMV_ is not one of 2, 4, 8, 10, 16, or 32, then _mathInt_ may be an implementation-approximated integer representing the integer value denoted by _numberString_ in radix-_radixMV_ notation.) - 1. If _mathInt_ = 0, then - 1. If _sign_ = -1, return *-0*𝔽. - 1. Return *+0*𝔽. + 1. If _sign_ = -1 and _mathInt_ = 0, return *-0*𝔽. 1. Return 𝔽(_sign_ × _mathInt_).
From 70b59424fe2c75275432357ffa5f64fb479fd71f Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 7/9] Editorial: Clarify derivation of _stripHexPrefix_ from _radixMV_ in parseInt --- spec.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec.html b/spec.html index 1a27693ad8..f01b58ccc4 100644 --- a/spec.html +++ b/spec.html @@ -30094,13 +30094,10 @@

parseInt ( _string_, _radix_ )

It performs the following steps when called:

1. Let _inputString_ be ? ToString(_string_). - 1. Let _stripHexPrefix_ be *true*. 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). - 1. If _radixMV_ ≠ 0, then - 1. If _radixMV_ < 2 or _radixMV_ > 36, return *NaN*. - 1. If _radixMV_ ≠ 16, set _stripHexPrefix_ to *false*. - 1. Else, - 1. Set _radixMV_ to 10. + 1. If _radixMV_ = 0 or _radixMV_ = 16, let _stripHexPrefix_ be *true*. + 1. Else if _radixMV_ ≥ 2 and _radixMV_ ≤ 36, let _stripHexPrefix_ be *false*. + 1. Else, return *NaN*. 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). 1. If _trimmedString_ is the empty String, return *NaN*. 1. Let _sign_ be 1. @@ -30112,6 +30109,7 @@

parseInt ( _string_, _radix_ )

1. If _stripHexPrefix_ is *true*, the length of _trimmedString_ ≥ 2, and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. 1. Set _radixMV_ to 16. + 1. If _radixMV_ = 0, set _radixMV_ to 10. 1. If _trimmedString_ contains a code unit that is not a radix-_radixMV_ digit, let _end_ be the index within _trimmedString_ of the first such code unit; else let _end_ be the length of _trimmedString_. 1. Let _numberString_ be the substring of _trimmedString_ from 0 to _end_. 1. If _numberString_ is empty, return *NaN*. From b30085a3427f776d033f7872ce165d5563cbdb3a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 8/9] Editorial: Separate _radixMV_ bounds checking from _stripHexPrefix_ initialization in parseInt --- spec.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index f01b58ccc4..8369134fed 100644 --- a/spec.html +++ b/spec.html @@ -30095,9 +30095,8 @@

parseInt ( _string_, _radix_ )

1. Let _inputString_ be ? ToString(_string_). 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). - 1. If _radixMV_ = 0 or _radixMV_ = 16, let _stripHexPrefix_ be *true*. - 1. Else if _radixMV_ ≥ 2 and _radixMV_ ≤ 36, let _stripHexPrefix_ be *false*. - 1. Else, return *NaN*. + 1. If _radixMV_ ≠ 0 and _radixMV_ is not in the inclusive interval from 2 to 36, return *NaN*. + 1. If _radixMV_ = 0 or _radixMV_ = 16, let _stripHexPrefix_ be *true*; else let _stripHexPrefix_ be *false*. 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). 1. If _trimmedString_ is the empty String, return *NaN*. 1. Let _sign_ be 1. From 41b9523e3ec049b8a87c45d5e60560616c7ebc48 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 29 Apr 2026 10:49:16 -0400 Subject: [PATCH 9/9] Editorial: Inline _stripHexPrefix_ in parseInt --- spec.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index 8369134fed..fd04cec5f1 100644 --- a/spec.html +++ b/spec.html @@ -30096,7 +30096,6 @@

parseInt ( _string_, _radix_ )

1. Let _inputString_ be ? ToString(_string_). 1. Let _radixMV_ be ℝ(? ToInt32(_radix_)). 1. If _radixMV_ ≠ 0 and _radixMV_ is not in the inclusive interval from 2 to 36, return *NaN*. - 1. If _radixMV_ = 0 or _radixMV_ = 16, let _stripHexPrefix_ be *true*; else let _stripHexPrefix_ be *false*. 1. Let _trimmedString_ be ! TrimString(_inputString_, ~start~). 1. If _trimmedString_ is the empty String, return *NaN*. 1. Let _sign_ be 1. @@ -30105,9 +30104,10 @@

parseInt ( _string_, _radix_ )

1. Set _trimmedString_ to the substring of _trimmedString_ from 1. 1. Else if the first code unit of _trimmedString_ is the code unit 0x002B (PLUS SIGN), then 1. Set _trimmedString_ to the substring of _trimmedString_ from 1. - 1. If _stripHexPrefix_ is *true*, the length of _trimmedString_ ≥ 2, and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then - 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. - 1. Set _radixMV_ to 16. + 1. If _radixMV_ = 0 or _radixMV_ = 16, then + 1. If the length of _trimmedString_ ≥ 2 and the substring of _trimmedString_ from 0 to 2 is either *"0x"* or *"0X"*, then + 1. Set _trimmedString_ to the substring of _trimmedString_ from 2. + 1. Set _radixMV_ to 16. 1. If _radixMV_ = 0, set _radixMV_ to 10. 1. If _trimmedString_ contains a code unit that is not a radix-_radixMV_ digit, let _end_ be the index within _trimmedString_ of the first such code unit; else let _end_ be the length of _trimmedString_. 1. Let _numberString_ be the substring of _trimmedString_ from 0 to _end_.