Skip to content
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

Editorial: String.prototype.matchAll iterators won't return null #3421

Open
susisu opened this issue Sep 7, 2024 · 1 comment · May be fixed by #3423
Open

Editorial: String.prototype.matchAll iterators won't return null #3421

susisu opened this issue Sep 7, 2024 · 1 comment · May be fixed by #3423

Comments

@susisu
Copy link

susisu commented Sep 7, 2024

Description:

The description of String.prototype.matchAll says:

Each iteration result's value is an Array containing the results of the match, or null if the String did not match.

However, if the string did not match, the iterator returns undefined, not null, as far as you don't use an object with a custom @@matchAll property instead of the standard RegExp.

(Possibly this is because the old reivision of the proposal stated it returns null but the description remains unchanged?)

eshost Output:

$ eshost -s -x "const it = 'A'.matchAll(/B/g); const r = it.next(); print(r.done); print(r.value)"
#### JavaScriptCore, SpiderMonkey, V8, V8 --harmony, XS
true
undefined
@ljharb
Copy link
Member

ljharb commented Sep 7, 2024

In the case where done is true, the value should be ignored, so i think we just need to tweak the description and remove the last clause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@ljharb @susisu and others