[Webkit-unassigned] [Bug 23418] New: Regular expression literals are not being "shared" inside a function

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jan 19 06:25:27 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=23418

           Summary: Regular expression literals are not being "shared"
                    inside a function
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: fredck at fredck.com


Try out the following code:

>>>

var a = function()
{
   this.regexp = /WebKit/;
}

b = new a();
c = new a();

alert( b.regexp == c.regexp );

<<<

It alerts "false" in WebKit (r39853) and IE. With FF and Opera instead, we have
"true", which I though was a browser bug.

But, after a check at the ECMA-262 specs, it looks like "true" is the correct
thing:

>>>

7.8.5 Regular Expression Literals

A regular expression literal is an input element that is converted to a RegExp
object (section 15.10) when it is scanned. The object is created before
evaluation of the containing program or function begins. Evaluation of the
literal produces a reference to that object; it does not create a new object.

<<<

I know it's weird, but webkit is buggy here, and it is always better to have
browsers working in the same way.


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list