Closed
Bug 203909
Opened 22 years ago
Closed 22 years ago
Behavior of built-in functions called as constructors should follow standard.
Categories
(Rhino Graveyard :: Core, defect)
Rhino Graveyard
Core
Tracking
(Not tracked)
VERIFIED
FIXED
1.5R5
People
(Reporter: igor, Assigned: norrisboyd)
Details
Attachments
(1 file, 1 obsolete file)
7.62 KB,
patch
|
Details | Diff | Splinter Review |
This is a Rhino version of bug 202019 , see the description there.
Reporter | ||
Comment 1•22 years ago
|
||
To resolve this in a uniform way I changed BaseFunction.constructor to always
call createObject and then run the call method so IdFunction and FunctionObject
needs to override only createObject and not the construct method itself. Then
IdFunction.createObject simply throws TypeError if the function is not
explicitly marked as constructor.
The current behavior of SM can be obtained if instead of throwing error,
IdFunction.createObject can call super.createObject.
The patch should cover all the standard library functions since all of them are
implemented in terms of IdFunction and they marked as constructors only when
the standard required it.
Reporter | ||
Comment 2•22 years ago
|
||
Attachment #122124 -
Attachment is obsolete: true
Reporter | ||
Comment 3•22 years ago
|
||
I committed the fix, now in Rhino shell:
js> new parseInt('1')
js: "<stdin>", line 1: uncaught JavaScript exception: TypeError: "parseInt" is
not a constructor. (<stdin>; line 1)
js> new String.prototype.toString()
js: "<stdin>", line 2: uncaught JavaScript exception: TypeError: "toString" is
not a constructor. (<stdin>; line 2)
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 4•22 years ago
|
||
Verified FIXED. But is the error message for |eval| correct?
Rhino 1.5 release 5 0000 00 00
js> var obj = new eval();
TypeError: [object global] is not a function.
Shouldn't the error message say, '"eval" is not a constructor'?
COMPARE:
js> var obj = new isFinite();
TypeError: "isFinite" is not a constructor.
js> var obj = new Date.parse();
TypeError: "parse" is not a constructor.
Status: RESOLVED → VERIFIED
Comment 5•22 years ago
|
||
Note: Igor has fixed the error message for |new eval();| in bug 204210.
See bug 204210 comment 4.
You need to log in
before you can comment on or make changes to this bug.
Description
•