Closed
Bug 254915
Opened 21 years ago
Closed 21 years ago
Broken "this" for name() calls (CVS tip regression)
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
1.6R1
People
(Reporter: igor, Assigned: igor)
Details
Attachments
(1 file)
|
10.94 KB,
patch
|
Details | Diff | Splinter Review |
Consider this test case:
/////////////////START/////////////////////////////////
var expect = "something";
var with_seed = new String(expect);
with_seed.valueOf2 = String.prototype.valueOf;
var value;
with (with_seed) {
with (new Object) {
value = valueOf2();
}
}
if (value === expect) {
print("OK");
} else {
print("FAILED!");
}
/////////////////END///////////////////////////////////
With CVS tip from 2004-08-09 instead of expected OK it generates:
js: "test.js", line 12: uncaught JavaScript runtime exception: TypeError: Method
"valueOf" called on incompatible object.
The reason for this is that during evaluation of valueOf2() inside the with
statement the code correctly locates valueOf2 in with_seed object. But then
during function call it uses the nearest with object (new Object in this case)
as "this" for the function.
| Assignee | ||
Comment 1•21 years ago
|
||
The fix moves all the essential code from getNameFunctionAndThis into name() in
ScriptRuntime where code has access to the proper scope information.
I also removed no longer used ScriptRuntime.getBase and made setName to take an
extra scope parameter for proper location of the top scope when bound argument
is null.
| Assignee | ||
Comment 2•21 years ago
|
||
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.5R6
You need to log in
before you can comment on or make changes to this bug.
Description
•