Closed Bug 351352 Opened 19 years ago Closed 14 years ago

Perl RegExp test 419: /^(a\1?){4}$/.exec('aaaaaaaaaa')

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bc, Unassigned)

References

()

Details

expected aaaaaaaaaa,aaaa (MSIE6 agrees) actual null note that Perl RegExp test 420 /^(a\1?){4}$/.exec('aaaaaaaaa') is null in SpiderMonkey and MSIE6
there is actually an even simpler example: search for a sequence of either 'a's or 'b's (like in /^(a+|b+)/): ((^a)|(^b)|\1)+
Wondering if x00000000 has any thoughts on this bug.
null is the correct result per ECMA because step 4 of RepeatMatcher sets all inner captures to undefined. SpiderMonkey fails to do that (bug 369778), but if the left parenthesis is visited again, then it will set its capture to the empty string, and that's what a backreference to an undefined capture should match. In ECMAScript, a backreference at the left hand side of the corresponding right parenthesis is always equivalent to (?:).
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.