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

Fix RegExp.prototype[Symbol.match] and String.prototype.match #1836

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

balajirrao
Copy link
Contributor

This PR includes two fixes based on the spec:

  1. RegExp.prototype[Symbol.match]: The spec requires that this method invoke the exec method of the regular expression in a loop.
  2. String.prototype.match: The spec mandates that this method call RegExp.prototype[Symbol.match].

As a result, a few new test262 tests now pass. The remaining failing tests in built-ins/RegExp/prototype/Symbol.match and built-ins/String/prototype/match are unrelated to this fix.

@@ -66,7 +66,7 @@ protected boolean isDone(Context cx, Scriptable scope) {
return true;
}

next = regExpExec(cx, scope);
next = NativeRegExp.regExpExec(regexp, string, cx, scope);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please pop down to line 98 and get rid of the private method "regExpExec" that's no longer used?

@gbrail
Copy link
Collaborator

gbrail commented Feb 19, 2025

This is great -- thanks! I looked at the test coverage and it looks good, and I see how many things it fixes. I'd appreciate it if you could remove that unused method (there's a warning from Errorprone about it in the build output). Thanks!

@balajirrao
Copy link
Contributor Author

@gbrail thanks for taking a look! Will fix, rebase and push once CI is back to green on master.

The spec requires that Symbol.match call the exec method in a loop.
As per the spec, it is simply supposed to invoke the Symbol.match
of the regexp.
@gbrail
Copy link
Collaborator

gbrail commented Feb 20, 2025

This looks very good -- thanks!

p.s. I'm about to finish reorganizing NativeString completely into lambda functions so this comes just in time

@gbrail gbrail merged commit dd8ab2e into mozilla:master Feb 20, 2025
3 checks passed
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 this pull request may close these issues.

2 participants