Closed Bug 225550 Opened 21 years ago Closed 21 years ago

RegExp toSource/toString return an invalid empty RE

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.6beta

People

(Reporter: thomas, Assigned: brendan)

Details

(Keywords: js1.5, Whiteboard: [ bug 226045 has been filed against Rhino for this same issue])

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6a) Gecko/20031029
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6a) Gecko/20031029

If I create an empty regular expression object an call toString or toSource on
it, I get "//" as the result. This isn't a valid RE string, since it's the start
of a comment:

var re    = new RegExp     // create an empty RE
var reSrc = re.toString()  // gives "//"
var re2   = eval(reSrc)    // gives "undefined" instead of an empty RE object

We should better return "/(?:)/" in this special case, as mentioned in ECMA262-3
7.8.5.

Reproducible: Always

Steps to Reproduce:




Most browsers (Mozilla, IE, Opera, iCab) show this behaviour, but a change for
this special case probably won't break any compatibility (I'm considering this
fix for iCab, too).
Confirming for consideration -
Status: UNCONFIRMED → NEW
Ever confirmed: true
.
Assignee: general → brendan
Keywords: js1.5
Priority: -- → P1
Target Milestone: --- → mozilla1.6beta
Attached patch proposed fixSplinter Review
Simple and direct.

/be
Checked in.

/be
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Hi,
Not happening in Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6b) Gecko/20031113
in windows.
Wellander3: what, do you think I have a time machine, and can go back to
yesterday and check in for the build dated 20031113?  Please.

/be
Status: RESOLVED → VERIFIED
Hi,
Sorry I am not asking you to go back to yesterday.
Whiteboard: [ bug 226045 has been filed against Rhino for this same issue]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: