nsIArray documentation (IndexOf, enumerate) is wrong.

RESOLVED FIXED in mozilla13

Status

()

Core
XPCOM
RESOLVED FIXED
10 years ago
6 years ago

People

(Reporter: standard8, Assigned: aceman)

Tracking

({dev-doc-complete})

Trunk
mozilla13
dev-doc-complete
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

nsIArray is a frozen interface, but its documentation is wrong:

indexOf() states that it:
@throws NS_ERROR_NOT_FOUND if the element was not in the array.

That's incorrect, it throws NS_ERROR_FAILURE: http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/xpcom/ds/nsArray.cpp&rev=1.14&mark=89,96#81

enumerate() also states that it:
@throws NS_ERROR_FAILURE if the array is empty (to make it easy to detect errors)

If you follow it through to NS_NewArrayEnumerator (http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/xpcom/glue/nsArrayEnumerator.cpp&rev=1.15&mark=111-121#111), you'll find that empty arrays are allowed. You may get NS_ERROR_OUT_OF_MEMORY thrown if we're out of memory of course...

So, should we fix the documentation, or the code?

In the IndexOf case NS_ERROR_NOT_FOUND isn't currently a provided error code, and the enumerate case I think it should just accept it as otherwise we're changing the functionality that folks may be relying on.

Comment 1

6 years ago
I just got caught by this.

"So, should we fix the documentation, or the code?"

Easier just to change the documentation.
(Assignee)

Comment 2

6 years ago
I'll fix the docs, as there is no NS_ERROR_NOT_FOUND defined in http://mxr.mozilla.org/comm-central/source/mozilla/xpcom/base/nsError.h .
Assignee: nobody → acelists
Keywords: dev-doc-needed
(Assignee)

Comment 3

6 years ago
Created attachment 598369 [details] [diff] [review]
patch for nsIArray.idl

Also patch the comments in code.
Attachment #598369 - Flags: review?(benjamin)
(Assignee)

Comment 4

6 years ago
Somebody also needs to update https://developer.mozilla.org/en/NsIArray . I had an account there but now it does not work due to BrowserID.
(Assignee)

Updated

6 years ago
Status: NEW → ASSIGNED

Updated

6 years ago
Attachment #598369 - Flags: review?(benjamin) → review+
(Assignee)

Comment 5

6 years ago
I could now finally login into MDN so I fixed the docs too.
Keywords: dev-doc-needed → checkin-needed, dev-doc-complete
http://hg.mozilla.org/integration/mozilla-inbound/rev/3ed99fc9760a
Keywords: checkin-needed
Target Milestone: --- → mozilla13

Comment 7

6 years ago
https://hg.mozilla.org/mozilla-central/rev/3ed99fc9760a
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.