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

Normative: correct spec bug in RegExp.prototype[Symbol.matchAll] #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -31129,7 +31129,8 @@ <h1>RegExp.prototype [ @@matchAll ] ( _string_ )</h1>
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. Let _S_ be ? ToString(_string_).
1. Let _C_ be ? SpeciesConstructor(_R_, %RegExp%).
1. Let _flags_ be ? ToString(? Get(_R_, `"flags"`)).
1. Let _flagsValue_ be ? Get(_R_, `"flags"`).
Copy link
Member

Choose a reason for hiding this comment

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

Do you think that @@split suffers from a similar issue?

var str = 'a\u{1d11e}b';
var pattern = /\u{1d11e}/u;
Object.defineProperty(pattern, 'flags', { value: undefined, configurable: true });
str.split(pattern);
// SyntaxError: Invalid flags supplied to RegExp constructor 'undefinedy'

undefinedy 🤣

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that also seems like the same spec bug to me.

I'd be happy to pursue changing this in the other methods too, if folks feel that's viable.

Copy link
Contributor

@rbuckton rbuckton Jul 23, 2019

Choose a reason for hiding this comment

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

If we're going to do this in multiple places, should we have something like a ToStringOrEmpty operation to handle undefined (or null)?

BTW: null is an issue too, both for matchAll and split

1. If _flagsValue_ is *undefined*, let _flags_ be the empty String, else let _flags_ be ? ToString(_flagsValue_).
1. Let _matcher_ be ? Construct(_C_, &laquo; _R_, _flags_ &raquo;).
1. Let _lastIndex_ be ? ToLength(? Get(_R_, `"lastIndex"`)).
1. Perform ? Set(_matcher_, `"lastIndex"`, _lastIndex_, *true*).
Expand Down