Closed
Bug 283477
Opened 20 years ago
Closed 20 years ago
String.prototype.lastIndexOf returns numbers smaller than -1 on failure
Categories
(Core :: JavaScript Engine, defect, P1)
Tracking
()
VERIFIED
FIXED
mozilla1.8beta2
People
(Reporter: sjoerd, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(1 file)
620 bytes,
patch
|
brendan
:
review+
|
Details | Diff | Splinter Review |
a.lastIndexOf(b, c) should return -1 when there is no match, but it returns a.length - b.length when a is shorter than b and c is, or can be converted to, a number. Example: "".lastIndexOf("hello", 0) returns -5 "".lastIndexOf("hello") returns -1
Assignee | ||
Comment 2•20 years ago
|
||
Conserving the original code structure, but if you follow ECMA-262 Edition 3, the code would be d = js_DoubleToInteger(d); i = (jsint) JS_MIN(JS_MAX(d, 0), textlen); Checking in now. /be
Attachment #175454 -
Flags: review+
Assignee | ||
Comment 3•20 years ago
|
||
Sjoerd, thanks very much! Surprising that the testsuite didn't insist on -1 for patlen > textlen, but there it is: a hole in test coverage. Not the last one, either! /be
Status: NEW → RESOLVED
Closed: 20 years ago
QA Contact: pschwartau → moz
Resolution: --- → FIXED
Reporter | ||
Comment 4•20 years ago
|
||
Well, if you write code for Mozilla, the whole world is your testsuite. My "Find previous" code always found matches on empty lines! But thanks for the quick response. Maybe if you have time you could add a comment (just a comment, not a fix) to bug 274888 too.
Updated•20 years ago
|
Flags: testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•