Closed
Bug 299644
Opened 19 years ago
Closed 19 years ago
Javascript's concat doesn't verify, if the properties exist.
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: mozilla, Assigned: mrbkap)
Details
Attachments
(2 files)
96 bytes,
text/plain
|
Details | |
2.20 KB,
patch
|
brendan
:
review+
brendan
:
approval1.8b3+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.0 (like Gecko) Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) According to ECMAscript spec (section 15.4.4.4 step 9) the concat function should test (for each element < array.length), if the array has an entry. An concat on an empty array (of non-0 length) should therefore produce an empty array. Reproducible: Always
the array "b", should be empty, as "a" doesn't contain any property. a "for ... in" should therefore not print anything.
Updated•19 years ago
|
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → 1.7 Branch
Assignee | ||
Comment 2•19 years ago
|
||
I think we may actually be following the spec here. Notice that step 9 says to go to step 13 if the property doesn't exist, but step 13 is incrementing n, so in the new array, this location would be a "hole" in the new array also. Also notice that step 22 sets the new array's length to be n, which in this case would be 10 (per step 13), giving us the correct answer. Am I missing anything? Note: I have a patch that reflects the spec. a bit better than the current code (and avoids calling OBJ_SET_PROPERTY() for the holes) that I'll attach in a second, but it preserves the same behavior (as far as I can tell) on the given testcase.
Version: 1.7 Branch → Trunk
Assignee | ||
Comment 3•19 years ago
|
||
I'm not sure if we want this patch. I *think* it's more "correct" than the current code, but I guess Brendan or Shaver get the final call on this.
Comment 4•19 years ago
|
||
mrbkap's right, the bug is INVALID as stated in comment 0 -- see ECMA-262 Ed. 3, 15.4.4.4 steps 9, 13, and 22. mrbkap: do you want to morph this bug, or is there a better bug in which to patch SpiderMonkey to preserve holes? /be
Assignee | ||
Comment 5•19 years ago
|
||
I'll mark this as INVALID and open a new bug to audit for Spidermonkey plugging holes in arrays.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
as far as I understood, in the test-case b should be identical to a. But when I do "for(var v in a) alert(v);" I will get no alert, but "for(var v in b) alert(v)" will alert ten times. Maybe my version is just too old (but I even tried on a 1.7.8). Maybe the given patch fixes this, but in this case it shouldn't be "invalid".
Comment 7•19 years ago
|
||
(In reply to comment #6) > as far as I understood, in the test-case b should be identical to a. But when > I do "for(var v in a) alert(v);" I will get no alert, but "for(var v in b) > alert(v)" will alert ten times. Maybe my version is just too old (but I even > tried on a 1.7.8). No, your version is not too old, but the summary in comment 0 is still invalid. (new Array(10).concat()).length must be 10 by ECMA-262 Ed. 3. > Maybe the given patch fixes this, but in this case it shouldn't be "invalid". The bug where we fill holes enumerably is valid, you're right. The claim that the concat result should be empty as in zero length is still invalid. mrbkap, let's make progress here with a spot fix, ok? /be
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Comment 8•19 years ago
|
||
Comment on attachment 188222 [details] [diff] [review] the promised patch r+a=me, thanks. /be
Attachment #188222 -
Flags: review+
Attachment #188222 -
Flags: approval1.8b3+
Assignee | ||
Updated•19 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Updated•19 years ago
|
Assignee: general → mrbkap
Status: ASSIGNED → NEW
Assignee | ||
Updated•19 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 9•19 years ago
|
||
Fix checked in. I filed bug 299738 on the more general problem of jsarray.c functions plugging holes in arrays.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → FIXED
Updated•19 years ago
|
Flags: testcase?
Comment 10•19 years ago
|
||
Checking in regress-299644.js; /cvsroot/mozilla/js/tests/js1_5/Array/regress-299644.js,v <-- regress-299644.js initial revision: 1.1
Flags: testcase? → testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•