Closed Bug 534951 Opened 15 years ago Closed 15 years ago

Wrong successive matches when using regular expression with 'g' flag

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 98409

People

(Reporter: michal, Unassigned)

Details

Attachments

(1 file)

Attached file testcase
Expected result of attached testcase is :
a
c

The actual result is that the script runs forever. First match of regexp_parse("abcd") is "ab" ("a" is remembered using parentheses). Then it recursively calls regexp_parse("a") that doesn't match anything. Next match should be "cd" but it is "ab" again. So it gets stuck in the loop.

Strange is that everything works as expected if regular expression is created using new RegExp("(.).", "g") instead of /(.)./g
We conform to ES3, which specifies this buggy behavior for RegExp literals (that they are singletons with shared mutable state).

/be
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: