-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Possible bug in GetSubstitution or test262 #1426
Comments
Probably an oversight in #853, which changed it from |
BTW, the wording ”no replacement is done” introduced in #853 is obscure (I first understood as: |
That seems right. I tested Chrome, Firefox and Edge. All behave like this: Should I try to do a PR to fix the spec? |
A PR for the fix would be great. If the browsers agree, I think we should change the spec to match them. Thank you for your good work here in catching my error! |
I ran that code in eshost and got this: codeprint('ABCDEFGHIJKL'.replace(/(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)(L)/, '$12'));
print('ABCDEFGHIJKL'.replace(/(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)/, '$12')); results#### Chakra
L
A2L
#### JavaScriptCore
L
A2L
#### SpiderMonkey
L
A2L
#### V8
L
A2L
#### V8 --harmony
L
A2L so if the spec disagrees with that, then a PR to fix the spec would be much appreciated! |
@targos any interest in making a PR? |
$nn patterns fall back to $n when there aren't at least nn captures Fixes tc39gh-1426
$nn patterns fall back to $n when there aren't at least nn captures Fixes tc39gh-1426
In anticipation of a fix for tc39#1426 (cf. tc39#2739 (comment) )
In anticipation of a fix for tc39#1426 (cf. tc39#2739 (comment) )
$nn patterns fall back to $n when there aren't at least nn captures Fixes tc39gh-1426
For those like myself wondering how we managed to fail to fix this the last time it was addressed, here's the meeting notes: https://github.com/tc39/notes/blob/main/meetings/2017-03/mar-22.md#853-stringprototypereplace-edge-case-alignment. It looks like we were only considering single-digit substitutions beyond the number of captures, not how double-digit substitutions would behave. |
$nn patterns fall back to $n when there aren't at least nn captures Fixes tc39#1426
I think I found a mismatch between the spec and some test262 tests.
In the table for Replacement Text Symbol Substitutions, the 5th row says "$n where n is one of 1 2 3 4 5 6 7 8 9 and $n is not followed by a decimal digit".
In the following test: https://github.com/tc39/test262/blob/master/test/built-ins/String/prototype/replace/S15.5.4.11_A3_T1.js
The substition string is
"$1115"
. This string does not match that row of the table ($1
is followed by the decimal digit1
), but the test result expects that it does ($1
is replaced by the first capture).Which is correct? Spect text or test?
The text was updated successfully, but these errors were encountered: