tc39 / proposal-regexp-match-indices

ECMAScript RegExp Match Indices
https://arai-a.github.io/ecma262-compare/?pr=1713
BSD 3-Clause "New" or "Revised" License
65 stars 13 forks source link

Fix off-by-one in groupNames #42

Closed rbuckton closed 3 years ago

rbuckton commented 4 years ago

Ensures groupNames is indexed with an offset -1 relative to the indices List.

Fixes #39

/cc @targos

rbuckton commented 4 years ago

Preview is at https://tc39.es/proposal-regexp-match-indices/pr/42/index.html#sec-makeindicesarray, changes at steps 5-6 and 12.e (was 11.e).

ljharb commented 4 years ago

Why would we want to fix this by prepending undefined, rather than changing the access points to correctly zero-index?

rbuckton commented 3 years ago

Why would we want to fix this by prepending undefined, rather than changing the access points to correctly zero-index?

Mostly to align it with indices. I can change groupNames to be off by one from indices, but I feel its worth adding a note somewhere to indicate why we use i - 1 in that algorithm, since its not clear from the algorithm itself.

rbuckton commented 3 years ago

I've updated https://github.com/tc39/proposal-regexp-match-indices/pull/42#issuecomment-613118031 to reflect the new changes based on PR feedback.

rbuckton commented 3 years ago

@ljharb can you take another look at this, now that its up-to-date with the d flag changes?