Closed Bug 331504 Opened 18 years ago Closed 18 years ago

RegEx caching is detrimental to testing

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 237111

People

(Reporter: cwolves, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

for(var i=0; i<10; i++)
   alert(/e/gi.test('e'));



The regular expression /e/gi is getting cached here.  It shouldn't be.  /e/gi should be declaring a new regular expression but it seems to be pulling from some sort of cache.

The above code is performing identically to:

var myRegEx = /e/gi;
for(var i=0; i<10; i++)
   alert(myRegEx.test('e'));

which it shouldn't be.


This might be a matter of opinion, or it may be outlined somewhere in detail in the specs for regex's.  I know that literal notation only compiles a regex once, but re-defining the regex -should- reset the internal counter as it does in every other browser I've tested.

Reproducible: Always

Steps to Reproduce:
run the above code.
Actual Results:  
true
false
true
false
true

Expected Results:  
true
true
true
true
true
Assignee: nobody → general
Component: JavaScript Console → JavaScript Engine
Product: Firefox → Core
QA Contact: javascript.console → general
Version: unspecified → Trunk

*** This bug has been marked as a duplicate of 237111 ***
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.