new RegExp().source should return "(?:)"

RESOLVED FIXED in Firefox 38

Status

()

defect
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: arai, Assigned: arai)

Tracking

({dev-doc-complete, site-compat})

Trunk
mozilla38
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox38 fixed, relnote-firefox 38+, relnote-b2g ?)

Details

(Whiteboard: [DocArea=JS])

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
Derived from bug 1120169.

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.source
> 7. Return EscapeRegExpPattern(src, flags).

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-escaperegexppattern
> If P is the empty String, this specification can be met by letting S be "(?:)".

Currently `source` property returns empty string, and RegExpObject::toString does the replacement.
Comment on attachment 8560963 [details] [diff] [review]
Return "(?:)" for source of RegExp with empty pattern.

Review of attachment 8560963 [details] [diff] [review]:
-----------------------------------------------------------------

Nice, thanks.
Attachment #8560963 - Flags: review?(till) → review+
Release Note Request (optional, but appreciated)
[Why is this notable]: Potentially backwards-incompatible change
[Suggested wording]: RegExp.prototype.source now returns "(?:)" instead of the empty string for empty regular expressions
[Links (documentation, blog post, etc)]:
[1] https://mail.mozilla.org/pipermail/es-discuss/2012-March/021919.html (Search for RegExp)
[2] https://mail.mozilla.org/pipermail/es-discuss/2012-March/020815.html

Note that this is a potential backwards-compatibility issue as pointed out in [1]. It's been in Safari since 2011 though, so it'll most likely work.
Assignee: nobody → arai_a
Status: NEW → ASSIGNED
relnote-firefox: --- → ?
relnote-b2g: --- → ?
Keywords: dev-doc-needed
Keywords: site-compat
Whiteboard: [DocArea=JS]
https://hg.mozilla.org/mozilla-central/rev/7b89d8a612eb
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Added to Aurora/DevEd releasenotes a:

Changed: RegExp.prototype.source now returns "(?:)" instead of the empty string for empty regular expressions
You need to log in before you can comment on or make changes to this bug.