Closed Bug 1130798 Opened 9 years ago Closed 9 years ago

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

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox38 --- fixed
relnote-firefox --- 38+
relnote-b2g --- ?

People

(Reporter: arai, Assigned: arai)

Details

(Keywords: dev-doc-complete, site-compat, Whiteboard: [DocArea=JS])

Attachments

(1 file)

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
Closed: 9 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.

Attachment

General

Created:
Updated:
Size: