Closed Bug 751124 Opened 12 years ago Closed 9 years ago

Regexps disjunctions evaluating in the wrong order

Categories

(Core :: JavaScript Engine, defect)

x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bugzilla, Unassigned)

References

Details

(Keywords: regression, Whiteboard: [js:p2])

/a|ab|^(x)+/.exec("defab") evaluates to ["ab",undefined]

The expected result would be ["a", undefined].

The expected result is returned if the regexp is changed to /(?:a|ab|^(x)+)/, /a|ab/, /(?:a|ab|^x+)/, /a|ab|^(?:x)+/, /a|ab|^(x+)/ or /a|ab|(x)+/

The wrong result is only returned if the last alternative has to start at the beginning of the string and contains a capture group that is allowed to exist multiple times.

ECMA-262 Edition 5.1 says that exec is executed like (python notation):
 1. Let i be one
 2. While u < len(input)
 3. Execute the regexp on input[1:]
 4. If there is a result
  5. Return result
 6. Increment i

And disjunctions are to be evaluated left to right. The first matching alternative will be the result.
Regression window(m-c)
Works:
http://hg.mozilla.org/mozilla-central/rev/b69d30cc0b24
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110606 Firefox/7.0a1 ID:20110606110214
Fails:
http://hg.mozilla.org/mozilla-central/rev/3589f8cefd83
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110606 Firefox/7.0a1 ID:20110606132754
Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=b69d30cc0b24&tochange=3589f8cefd83

Regression window(tm)
Works:
http://hg.mozilla.org/tracemonkey/rev/fe3c9a76eeae
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a1) Gecko/20110524 Firefox/6.0a1 ID:20110525085637
Fails:
http://hg.mozilla.org/tracemonkey/rev/c8695a65e1e7
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a1) Gecko/20110525 Firefox/6.0a1 ID:20110525145421
Pushlog:
http://hg.mozilla.org/tracemonkey/pushloghtml?fromchange=fe3c9a76eeae&tochange=c8695a65e1e7

Suspected:
cc36a234d0d6	David Mandelin — Bug 625600: Update Yarr import to WebKit rev 86639, r=cdleary,dvander
Blocks: 625600
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
OS: Windows 7 → All
Version: unspecified → Trunk
Whiteboard: [js:p2]
Assignee: general → nobody
No longer reproducible - resolving as WFM. (Note: YARR was removed in bug 1024038.)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.