Closed
Bug 380182
Opened 18 years ago
Closed 17 years ago
undetectable property: Error.prototype.stack
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: dhtmlkitchen, Unassigned)
References
()
Details
"stack" in Error.prototype; // false
Error.prototype.stack; // undefined
Error.prototype.stack should be detectable without throwing an error.
Comment 1•18 years ago
|
||
What error does it throw? What are the expected and actual results? Can you provide a testcase?
Product: Firefox → Core
QA Contact: general → general
Reporter | ||
Comment 2•18 years ago
|
||
> What error does it throw
Throws no error.
> What are the expected and actual results?
Expected:
"stack" in Error.prototype;// should be true, regardless of the value.
I'd normally expect an empty Stack from a "stack" property (or getStack method)
Testcase: Type into Firebug, click run:
Error.prototype.stack;
Comment 3•18 years ago
|
||
Why do you expect Error.prototype.stack to exist?
Reporter | ||
Comment 4•18 years ago
|
||
stack property is on an error instance.
https://bugzilla.mozilla.org/show_bug.cgi?id=123177
I expected it would be in the prototype.
Comment 5•17 years ago
|
||
The property is just defined on the error object directly when it's thrown:
+ ok = JS_DefineProperty(cx, obj, js_stack_str,
+ STRING_TO_JSVAL(stack),
+ NULL, NULL, JSPROP_ENUMERATE);
(from the patch in the cited bug). So no, it's not on the prototype.
Updated•17 years ago
|
Assignee: nobody → general
Component: General → JavaScript Engine
QA Contact: general → general
Version: unspecified → Trunk
Comment 6•17 years ago
|
||
Not all prototypes are instances of the class they proto for; this is, I think one of those cases. I also think that is fine behavior.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
Comment 7•17 years ago
|
||
Prototypes are odd, they should appear to be instances of their class (ES3 notably dictates that RegExp.prototype is Object, but browsers don't do that and ES4 is fixing to match the de-facto standard), but if you get picky about their type you can see they must be of a different type from instances.
But that's neither here nor there. The stack property is a property of each thrown Error instance, not of Error.prototype:
js> try { function f(){throw new Error("moo")}; f()}catch(e){E=e}
Error: moo
js> 'stack' in E
true
js> 'stack' in Error.prototype
false
js> for (i in Error.prototype) print(i)
name
message
fileName
lineNumber
js> for (i in Error.prototype) print(Error.prototype[i])
Error
0
js> Error.prototype.constructor
function Error() {
[native code]
}
js> E.constructor
function Error() {
[native code]
}
/be
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•