The ECMA v3 spec says (15.11.1) that when Error() is called as a function it works just as when it is called as a constructor. The same goes for the other Error types like TypeError(). This doesn't work right in js-1.5-rc1
oops. I forgot to mention. What Error() does when called as a function is to simply return undefined. It should return an Error object
This is what I'm getting in the JS shell (pulled 2000-10-11): js> var x = Error() js> typeof(x) undefined js> var x = new Error() js> typeof(x) object
Here is the relevant passage from ECMA Version 3: 15.11 Error Objects Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes. 15.11.1 The Error Constructor Called as a Function When Error is called as a function rather than as a constructor, it creates and initialises a new Error object. Thus the function call Error(…) is equivalent to the object creation expression new Error(…) with the same arguments.
The Exception super-duper constructor doesn't set rval for the not-constructing case. Here's a patch. Don't think this is rtm level though.
This was fixed on the trunk a while ago. I don't think the fix got into the branch, but it should be considered for standards-conformance reasons. We have a patch that already got reviewed as part of a larger patch. I'll re-record my firstname.lastname@example.org here, ask mccabe to do the same with r=, and ask further that we put this up for [rtm+]. /be
Marking [rtm need info] since this is in progress. Brendan, you mention standards conformance, but what real world sites would be broken by this? If it's just future compatibility, then this seems like just another bug (and the trunk is already fixed.) What could possibly be broken by taking this fix?
Updating status whiteboard. /be
rtm-, still don't see any impacted sites mentioned. The train is leaving and we're not looking for general cleanup fixes.
Standards conformance fixes are not "general" cleanup, they're specific, as in, follow the specification. I believe jst plead a similar bug (case sensitivity in one HTML DOM method vs. insensitivity in the standard and in another that we implement correctly). These are one-line fixes that make the product better in specific, standardized ways. I don't see why they are less important than other specific fixes for crash and data-loss bugs, although I appreciate the PDT's efforts to close down changes and get the train moving. /be
are we keeping this one open for 6.01, or should it be marked as fixed since the fix is in the trunk?
Not a 6.01 thing.