Bug 16752

Summary: backreferences to nonexistent subexpressions should raise according to ES3
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: barraclough, darin, ian, jwalden+bwo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.4   

Eric Seidel (no email)
Reported 2008-01-05 14:23:24 PST
back-references to non-existent selectors should raise (acid3 bug) function () { // test 86: Regular Expressions var ok = true; try { eval("/TA[])]/.exec('TA]')"); // JS regexps aren't like Perl regexps, if their character // classes start with a ] that means they're empty. So this // is a syntax error; if we get here it's a bug. ok = false; } catch (e) { } assert(ok, "orphaned bracket not considered parse error in regular expression literal"); try { if (eval("/[]/.exec('')")) ok = false; } catch (e) { ok = false; } assert(ok, "/[]/ either failed to parse or matched something"); var x = /(\3)(\1)(a)/.exec('cat'); // the \3 matches the empty string, qv. ES3:15.10.2.9 assert(x, "/(\\3)(\\1)(a)/ failed to match 'cat'"); assert(x.length == 4, "/(\\3)(\\1)(a)/ failed to return four components"); assert(x[0] == "a", "/(\\3)(\\1)(a)/ failed to find 'a' in 'cat'"); assert(x[1] == "", "/(\\3)(\\1)(a)/ failed to find '' in 'cat' as first part"); assert(x[2] == "", "/(\\3)(\\1)(a)/ failed to find '' in 'cat' as second part"); assert(x[3] == "a", "/(\\3)(\\1)(a)/ failed to find 'a' in 'cat' as third part"); try { eval("/(1)(2)(3)\6(4)(5)/"); ok = false; } catch (e) { } assert(ok, "should have raised syntax error for a backreference to a non-existent capture"); try { eval("/(1)\0(2)/"); ok = false; } catch (e) { } assert(ok, "should have raised syntax error for a backreference to the zeroth capture"); return 6; },
Attachments
Eric Seidel (no email)
Comment 1 2008-01-30 01:08:56 PST
This is now called Test 90 and the test has changed so that we seem to PASS. Would you like to keep this open Darin? If so we should remove the "(Acid3 bug)"
Darin Adler
Comment 2 2008-01-30 05:07:55 PST
Seems fine to keep it open.
Ian 'Hixie' Hickson
Comment 3 2008-01-30 16:20:57 PST
brendan seemed to suggest this would change in ES4. I recommend pushing for that since we have interop on this already anyway.
Darin Adler
Comment 4 2008-01-30 16:35:10 PST
OK, so we probably should not change the behavior.
Gavin Barraclough
Comment 5 2012-09-06 18:06:29 PDT
Removing octal escapes would break the web, and ecmascript permits syntax extensions.
Note You need to log in before you can comment on or make changes to this bug.