Bug 55040 - RegExp constructor returns the argument regexp instead of a new object
Summary: RegExp constructor returns the argument regexp instead of a new object
Status: RESOLVED FIXED
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: 2011-02-23 04:56 PST by Kent Hansen
Modified: 2011-06-28 11:36 PDT (History)
3 users (show)

See Also:


Attachments
Thepatch (6.04 KB, patch)
2011-06-28 11:22 PDT, Gavin Barraclough
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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