Repository navigation
Conversation
RegExp.prototype.test must use RegExpExec after coercing its argument to a string. Calling the builtin implementation directly bypasses overridden exec methods and rejects otherwise valid generic object receivers. Use the existing RegExpExec implementation, including its object-or-null return check. Inline the now single-use exec helper into its entrypoint. Cover dispatch, coercion order, getter effects, invalid returns, exceptions and noncallable exec fallback on real RegExp objects.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RegExp.prototype.testcurrently invokes the builtin matcher directly. That ignores an overriddenexecand rejects generic object receivers whose callableexecreturns an object or null.Use the existing
RegExpExecimplementation after checking the receiver and coercing the argument to a string. This preserves the specified ordering when string coercion changesexec, invokes anexecgetter once, validates custom results, and retains builtin fallback for a real RegExp with a noncallableexec.The now single-use builtin exec helper is inlined into
regExpPrototypeExec. This PR contains the dispatch correction only; result-allocation optimizations are separate.Test Plan
The new regression covers custom methods, generic receivers, invalid primitive results, non-object receivers, noncallable fallback, coercion/getter/call ordering, mutation during coercion, propagated exceptions and a getter returning the builtin method.
Built Hermes from this branch. The regression passed in normal execution,
-O, and emitted-bytecode execution. The same assertions also passed in Node as a reference implementation.