Closed Bug 302501 Opened 19 years ago Closed 19 years ago

constructor property shouldn't be readonly

Categories

(Rhino Graveyard :: Core, defect)

1.6R1
x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: norrisboyd, Assigned: norrisboyd)

Details

Test case:

function f() { }
function g() { }
f.prototype.constructor = g;
print(f.prototype.constructor == g);

Should print "true".
Fix:

Index: BaseFunction.java
===================================================================
RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/BaseFunction.java,v
retrieving revision 1.54
diff -u -r1.54 BaseFunction.java
--- BaseFunction.java	6 Feb 2005 01:56:46 -0000	1.54
+++ BaseFunction.java	28 Jul 2005 14:07:58 -0000
@@ -407,9 +407,7 @@
     private void setupDefaultPrototype()
     {
         NativeObject obj = new NativeObject();
-        final int attr = ScriptableObject.DONTENUM |
-                         ScriptableObject.READONLY |
-                         ScriptableObject.PERMANENT;
+        final int attr = ScriptableObject.DONTENUM;
         obj.defineProperty("constructor", this, attr);
         // put the prototype property into the object now, then in the
         // wacky case of a user defining a function Object(), we don't

Checking in BaseFunction.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/BaseFunction.java,v  <--  B
aseFunction.java
new revision: 1.55; previous revision: 1.54
done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.