[Webkit-unassigned] [Bug 32458] New: /g regex Literals do not save state across function invocations

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 11 22:05:30 PST 2009


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

           Summary: /g regex Literals do not save state across function
                    invocations
           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: joepeck at webkit.org
                CC: oliver at apple.com, aroben at apple.com


JavaScriptCore's literal regexs, do not save state (lastIndex) in functions,
but other JavaScript implementations do:

I believe the relevant section of the of ES3 Specification is:
15.10.6.2 RegExp.prototype.exec(string)

Local Regex:
------------

  var s='123aaa456';
  function foo(a) { return /\d+/g.exec(a); };
  [foo(s), foo(s)]


  Results:
  jsc:    [["123"],["123"]]  <-- Different Value
  v8:     [["123"],["456"]]
  rhino:  [["123"],["456"]]
  spider: [["123"],["456"]]


Note that when the regex is not local, but something that stays in scope the
entire time, it works as expected.

Global Regex:
-------------

  var s = '123aaa456';
  var r = /\d+/g;
  function foo(a) { return r.exec(a); };
  [foo(s), foo(s)]


  Results are all good:
  jsc:    [["123"],["456"]]
  v8:     [["123"],["456"]]
  rhino:  [["123"],["456"]]
  spider: [["123"],["456"]]

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



More information about the webkit-unassigned mailing list