Closed
Bug 726477
Opened 13 years ago
Closed 13 years ago
getOwnPropertyNames lies on Error objects
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 724768
People
(Reporter: erights, Unassigned)
Details
Seen on FF Nightly 13.0a1 (2012-02-12):
> var er = new Error('msg');
> Object.getOwnPropertyNames(er).sort().join('\n');
> Object.keys(er).sort().join('\n');
> var names = [];
> for (var n in er) { names.push(n); }
2
> names
fileName,lineNumber
> ['fileName', 'lineNumber', 'message', 'stack'].filter(function(n) { return !!Object.getOwnPropertyDescriptor(er, n); });
fileName,lineNumber,message,stack
According to getOwnPropertyNames() and keys(), er has no own properties. According to getOwnPropertyDescriptor() it has four. According to for/in, it has two enumerable properties, two of which are among the own properties reported by getOwnPropertyDescriptor().
This behavior is terribly inconsistent and confusing, leading to bad bugs in meta-programming code.
Comment 1•13 years ago
|
||
Pretty sure this is a dup of a bug on Error objects having no enumerate hook.
Whiteboard: DUPEME
Updated•13 years ago
|
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
You need to log in
before you can comment on or make changes to this bug.
Description
•