Closed
Bug 103351
Opened 23 years ago
Closed 23 years ago
'abc'.replace(undefined, 'Z') should be 'abc', not 'Zabc'
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
FIXED
mozilla0.9.9
People
(Reporter: pschwartau, Assigned: khanson)
Details
(Keywords: js1.5)
Attachments
(1 file)
1.42 KB,
patch
|
khanson
:
review+
brendan
:
superreview+
|
Details | Diff | Splinter Review |
This bug grew out of bug 83293. Bug 83293 addressed this: 'abc'.replace('', 'Z') should be 'Zabc' SpiderMonkey gave no return. Here we consider this: 'abc'.replace(undefined, 'Z') should be 'abc' SpiderMonkey returns 'Zabc' Both bugs derive from ECMA-262 Final Edition, Section 15.5.4.11 String.prototype.replace (searchValue, replaceValue) The Final Edition states that searchValue, if not of type RegExp, should be converted to String(searchValue), and the replace() method should then search for the first occurrence of this string and replace it. So, since String(undefined) == 'undefined', and there is no occurrence of 'undefined' in the string 'abc', we should have: 'abc'.replace(undefined, 'Z') == 'abc'
Reporter | ||
Comment 1•23 years ago
|
||
Note: the ECMA Final Edition differs vis-a-vis the ECMA Final Draft on the syntax for the replace() method, and is inconsistent with the Final Edition syntax for the related methods search(), match() of String.prototype in the case where searchValue is not of type RegExp. See bug 83293 for details. The testcase for this bug is js/tests/ecma_3/String/regress-83293.js
Keywords: js1.5
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.7
Comment 4•23 years ago
|
||
Hoping kenton doesn't mind the intrusion, I was working on related stuff and believe simply taking out the special handling for 'undefined' will do the job...
Comment 5•23 years ago
|
||
Comment on attachment 68823 [details] [diff] [review] proposed Patch is not up to date with respect to the cvs trunk, but no worries -- just update before you commit, no need for another patch. sr=brendan@mozilla.org. /be
Attachment #68823 -
Flags: superreview+
Assignee | ||
Comment 6•23 years ago
|
||
Comment on attachment 68823 [details] [diff] [review] proposed r=khanson
Attachment #68823 -
Flags: review+
Comment 7•23 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 8•23 years ago
|
||
Marking Verified FIXED. The testcase above, ecma_3/String/regress-83293.js, now passes in the debug/optimized JS shell on WinNT, Linux, and Mac9.1.
Status: RESOLVED → VERIFIED
Updated•19 years ago
|
Flags: testcase?
Updated•19 years ago
|
Flags: testcase? → testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•