Bug 103825 - [ES5.1 - 15.10.6.2] RegExp.prototype.exec(string), step 5 "ToInteger(lastIndex)" not always executed
Summary: [ES5.1 - 15.10.6.2] RegExp.prototype.exec(string), step 5 "ToInteger(lastInde...
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-01 17:37 PST by André Bargull
Modified: 2012-12-03 10:40 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description André Bargull 2012-12-01 17:37:29 PST
Step 5 of [ES5.1 - 15.10.6.2] RegExp.prototype.exec(string) must always be executed due to side effects. This affects not only plain calls to RegExp.prototype.exec, but also RegExp.prototype.test, String.prototype.match and String.prototype.replace, because these functions call directly or indirectly RegExp.prototype.exec. 

List of different javascript engines/browsers and the result for each test:
---
r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; r.exec("zzzz");
Bad: JSC, IE
Good: V8, SM, Opera

r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; r.test("zzzz");
Bad: JSC, IE, Opera
Good: V8, SM

r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; "zzzz".match(r);
Bad: JSC, IE, V8, SM
Good: Opera

r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; "zzzz".replace(r, "");
Bad: JSC, IE, V8, SM, Opera
Good: -
---