RegExp toSource/toString return an invalid empty RE

VERIFIED FIXED in 1.5R5

Status

VERIFIED FIXED
15 years ago
15 years ago

People

(Reporter: pschwartau, Assigned: igor)

Tracking

other
1.5R5
x86
All

Details

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
SpiderMonkey recently changed the behavior of toString() and toSource()
when applied to a RegExp object with an empty pattern. Do we want 
Rhino to stay in synch?

This is the Rhino analogue of bug 225550 against SpiderMonkey.
The testcases for this are:

      mozilla/js/testsecma_2/RegExp/properties-001.js
      mozilla/js/testsjs1_2/regexp/toString.js


Here is a comparison of the current SpiderMonkey and Rhino:

RHINO:
[/] java org.mozilla.javascript.tools.shell.Main
Rhino 1.5 release 5 0000 00 00
js> (new RegExp).toString();
//
js> (new RegExp).toSource();
//


SPIDERMONKEY:
[//d/JS_TRUNK/mozilla/js/src/WINNT4.0_DBG.OBJ] ./js
js>
js> (new RegExp).toString();
/(?:)/
js> (new RegExp).toSource();
/(?:)/


The new approach lets eval() turn this string back into the empty regexp.
The old approach doesn't work, since "//" is a comment, not a regexp.
(Reporter)

Comment 1

15 years ago
Oops, those tests are

      mozilla/js/tests/ecma_2/RegExp/properties-001.js
      mozilla/js/tests/js1_2/regexp/toString.js
(Assignee)

Comment 2

15 years ago
I will fix it.
Assignee: nboyd → igor
(Assignee)

Comment 3

15 years ago
Created attachment 136232 [details] [diff] [review]
Fix for NativeRegExp.toString()
(Assignee)

Comment 4

15 years ago
I committed the fix
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
(Reporter)

Comment 5

15 years ago
Verified FIXED.

The above testcases used to fail in both the compiled and interpreted
modes of Rhino. Now they pass in both -
Status: RESOLVED → VERIFIED
(Assignee)

Comment 6

15 years ago
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.