-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Normative: Don't call well-known Symbol methods for RegExp
on primitive values
#3009
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
base: main
Are you sure you want to change the base?
Normative: Don't call well-known Symbol methods for RegExp
on primitive values
#3009
Conversation
@petamoriken can someone from deno add this to the March meeting agenda? |
@lucacasonato Would you work on this issue? |
ca31671
to
25424af
Compare
I can see that this change would cause this to no longer evaluate to “surprise”: String.prototype[Symbol.split] = () => "surprise";
"a.b.c".split("."); I see no obvious downside to the proposed change in a vacuum, but given it’s a breaking change, I’m curious whether there’s been research yet on whether it’s web compatible in practice? (It seems plausible that it could be safe, but it also seems plausible that faithful polyfill implementations, e.g. @zloirock’s core-js, could be impacted). |
|
25424af
to
5942961
Compare
5942961
to
f9d3b02
Compare
f9d3b02
to
c45ae45
Compare
RegExp
on primitive valuesRegExp
on primitive values
The const isObject = v => Object(v) === v; |
c45ae45
to
9b254aa
Compare
9b254aa
to
cd6e94f
Compare
Test262 PR has landed. |
https://bugs.webkit.org/show_bug.cgi?id=290684 Reviewed by NOBODY (OOPS!). This patch implements tc39/ecma262#3009. test262 has been updated for it already[1]. [1]: tc39/test262@abc22b5 * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/builtins/StringPrototype.js: (match): (matchAll): (intrinsic.StringPrototypeReplaceIntrinsic.replace): (intrinsic.StringPrototypeReplaceAllIntrinsic.replaceAll): (search): (split):
https://bugs.webkit.org/show_bug.cgi?id=290684 Reviewed by NOBODY (OOPS!). This patch implements tc39/ecma262#3009. test262 has been updated for it already[1]. [1]: tc39/test262@abc22b5 * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/builtins/StringPrototype.js: (match): (matchAll): (intrinsic.StringPrototypeReplaceIntrinsic.replace): (intrinsic.StringPrototypeReplaceAllIntrinsic.replaceAll): (search): (split):
https://bugs.webkit.org/show_bug.cgi?id=290684 Reviewed by Yusuke Suzuki. This patch implements tc39/ecma262#3009. test262 has been updated for it already[1]. [1]: tc39/test262@abc22b5 * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/builtins/StringPrototype.js: (match): (matchAll): (intrinsic.StringPrototypeReplaceIntrinsic.replace): (intrinsic.StringPrototypeReplaceAllIntrinsic.replaceAll): (search): (split): Canonical link: https://commits.webkit.org/292913@main
… on primitives r=dminor,iain This patch adds telemetry for tc39/ecma262#3009. That normative PR has already been approved by TC39, but we need to verify that it's web compatible. Differential Revision: https://phabricator.services.mozilla.com/D241305
Fixed that methods for
RegExp
, such as@@split
, are not called on primitive values.Background
The internal code of runtimes such as Node.js and Deno are implemented that they work without problems even if they are polluted with prototypes. With this normative change in place, those runtimes don't need to worry if changes to
String.prototype[Symbol.split]
are polluted.On the other hand, if this normative change is not approved, the following workaround will have to be provided:
This approach could cause performance issue.
downstream: denoland/deno#17473