Closed Bug 193555 Opened 22 years ago Closed 22 years ago

1.5R4 regression: function expression has no access to its name

Categories

(Rhino Graveyard :: Core, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
1.5R4.1

People

(Reporter: user, Assigned: norrisboyd)

References

Details

Attachments

(1 file)

In 1.5R4 a function expression can not access its function name. To test, run the following test case in the Rhino shell with arbitrary optimization: var x = function f() { return f.toString(); }; var ok = (x.toString() === x()); print(ok ? "OK" : "FAILED"); In Rhino 1.5R3 it prints OK while running 1.5R4 produces: js: "/home/igor/js/x/f_rec.js", line 2: uncaught JavaScript exception: ReferenceError: "f" is not defined. (/home/igor/js/x/f_rec.js; line 2)
I wish I would be more careful when made the changes to VraibaleTable. In NodeTransformer.addVariables() in 1.4R3 had a condition "vars.getLocal(name) == null" which I replaced by "vars.hasLocal(name)" thus disabling access to the function name. On the other hand even the test suite does not have a check for that, so it seems this feature quite unknown. In any case, this one line patch to NodeTransformer.addVariables() restores the functionality.
Testcase added to JS testsuite: mozilla/js/tests/ecma_3/Function/regress-193555.js
Testcase passes in SpiderMonkey; and as Igor reports, it passes if I run version 1.5R3 of Rhino. Fails in 1.5RC4 with the error Igor reports -
Marking fixed as I commited the fix some time ago
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified FIXED. The above testcase now passes in the Rhino shell, in both compiled and interpreted mode -
Status: RESOLVED → VERIFIED
Blocks: 196149
Targeting as resolved against 1.5R4.1
Target Milestone: --- → 1.5R4.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: