Closed Bug 220584 Opened 21 years ago Closed 21 years ago

Script() result has no prototype and scope chains

Categories

(Rhino Graveyard :: Core, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

Details

Attachments

(1 file)

When Script object is called as a function, its result does not have properly
initialized prototype and scope chains so various Script.prototype methods
including toString does not work.

For example, calling 
var s = Script("1;");
print(s.__proto__ != null)
print(s.__parent__ != null)
print(s)

gives 
false
false
js: "<command>", line 3: uncaught JavaScript exception:
java.lang.RuntimeException: org.mozilla.javascript.PropertyException:
Constructor for "TypeError" not found.

instead of expected: 
true
true

1;

This is a semi-regression in rhino CVS compared with Rhino 1.5 Release 4.1 since
there the bug is only present in the interpreter.

Note that calling Script as a constructor works without any problems.
The propagation of the bug into the optimizer happens during changes to make
optimizer to generate single class when made code for Script initialization
shared between compiler and interpreter. 
Status: NEW → ASSIGNED
If Script is called as a constructor, it will get the proper parent and
prototype from the generic code to initialize newly constructed objects but if
it is called as a function, then it is the responsibility of the call
implementation to do the job.
I committed the fix
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Testcase added to JS testsuite:

      mozilla/js/tests/js1_5/Scope/regress-220584.js

Before Igor's fix, failed in Rhino exactly as described above.
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: