Bug 55040

Summary: RegExp constructor returns the argument regexp instead of a new object
Product: WebKit Reporter: Kent Hansen <kent.hansen>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, cmarcelo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Thepatch oliver: review+

Description Kent Hansen 2011-02-23 04:56:52 PST
In the following script, the last comparison

r = new RegExp;
r2 = new RegExp(r);
r == r2;

should produce false; however, with JSC it produces true. I.e., the "copy-constructing" call to RegExp doesn't return a new object.
In both V8 and SpiderMonkey, a new object is returned, as per ECMA-262 5th edition, section 15.10.4.
Comment 1 Gavin Barraclough 2011-06-28 11:22:09 PDT
Created attachment 98947 [details]
Thepatch
Comment 2 WebKit Review Bot 2011-06-28 11:24:11 PDT
Attachment 98947 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1

Source/JavaScriptCore/runtime/RegExpConstructor.cpp:305:  An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Gavin Barraclough 2011-06-28 11:36:06 PDT
fixed in r89946