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
Thanks, this bug is almost ten years old! Fix forthwith. /be
Assignee: general → brendan
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta2
Created attachment 175454 [details] [diff] [review] fix 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+
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
Last Resolved: 13 years ago
QA Contact: pschwartau → moz
Resolution: --- → FIXED
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.
js/tests/js1_5/Regress/regress-283477.js checked in.
verified fixed 1.8.x and trunk.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.