Closed
Bug 313570
Opened 20 years ago
Closed 20 years ago
length property of objects whose prototype chain includes a function is undefined
Categories
(Core :: JavaScript Engine, defect, P3)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
mozilla1.9alpha1
People
(Reporter: stryker330, Assigned: brendan)
Details
Attachments
(1 file)
1.15 KB,
patch
|
mrbkap
:
review+
shaver
:
superreview+
|
Details | Diff | Splinter Review |
While trying to develop a workaround for bug 313568, I discovered that an object whose prototype chain has a function object is undefined and can't be changed. For ex:
function tmp() {}
tmp.prototype = function(a, b, c) {};
var obj = new tmp();
//obj.length is undefined
obj.length = 10;
//obj.length is still undefined
Also, obj.hasOwnProperty('length') returns true.
IE always outputs the original function's length, which would be 3 in this case and is also immutable. Opera allows obj.length to be changed.
Assignee | ||
Comment 1•20 years ago
|
||
Taking. JSPROP_SHARED is deep when used with JSPROP_PERMANENT, which makes hasOwnProperty true all the way down the delegation chain (it's meant to apply only to function instances, so they each seem to have a 'length' direct property even though they are all delegating to Function.prototype).
The inability to get o.length and see the prototype's arity (3 in your example) is a somewhat separate (or separable) bug. It might be the thing to fix first.
/be
Assignee: general → brendan
OS: Windows XP → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → mozilla1.9alpha
Reporter | ||
Comment 2•20 years ago
|
||
Actually, the length property being immutable may be part of the spec. [[Put]] calls [[CanPut]] as its first step and [[CanPut]] seems to say that if any property in the prototype chain is ReadOnly, return false.
Assignee | ||
Comment 3•20 years ago
|
||
(In reply to comment #2)
> Actually, the length property being immutable may be part of the spec. [[Put]]
> calls [[CanPut]] as its first step and [[CanPut]] seems to say that if any
> property in the prototype chain is ReadOnly, return false.
Right, so bug 313568 is invalid, and the part of this bug that wants to set obj.length = 10 is invalid too -- but the bits about obj.length being undefined, and obj.hasOwnProperty('length') being true are valid.
/be
Reporter | ||
Updated•20 years ago
|
Summary: length property of objects whose prototype chain includes a function is undefined and immutable → length property of objects whose prototype chain includes a function is undefined
Comment 4•20 years ago
|
||
Checking in regress-313570.js;
/cvsroot/mozilla/js/tests/ecma_3/Function/regress-313570.js,v <-- regress-313570.js
initial revision: 1.1
done
Flags: testcase+
Assignee | ||
Comment 5•20 years ago
|
||
Note the lack of fun_setProperty -- all the built-in properties are readonly, so we know that if fun_getProperty is being called, there is no shadowing property in a more direct object along the prototype chain, therefore we should find the first function object on the chain.
/be
Attachment #205451 -
Flags: superreview?(shaver)
Attachment #205451 -
Flags: review?(mrbkap)
Comment 6•20 years ago
|
||
Comment on attachment 205451 [details] [diff] [review]
proposed fix
r=mrbkap
Attachment #205451 -
Flags: review?(mrbkap) → review+
Comment 7•20 years ago
|
||
Comment on attachment 205451 [details] [diff] [review]
proposed fix
sr=shaver. silly special function objects!
Attachment #205451 -
Flags: superreview?(shaver) → superreview+
Assignee | ||
Comment 8•20 years ago
|
||
Fixed.
/be
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 9•20 years ago
|
||
with 20051217 builds on win/mac/linux
<http://test.bclary.com/tests/mozilla.org/js/js-test-driver-standards.html?test=ecma_3/Function/regress-313570.js;language=language;javascript>
BUGNUMBER: 313570
STATUS: length of objects whose prototype chain includes a function
FAILED!: length of objects whose prototype chain includes a function: inherited
FAILED!: Expected value 'false', Actual value 'true'
FAILED!:
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 10•20 years ago
|
||
Restoring FIXED mark -- Bob, the hasOwnProperty result is expected given the design of SpiderMonkey, and it's independent of this bug or its fix. Could you please spin out a new bug? Thanks,
/be
Status: REOPENED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → FIXED
Comment 11•20 years ago
|
||
filed Bug 320854
You need to log in
before you can comment on or make changes to this bug.
Description
•