-
Bug
-
Resolution: Fixed
-
P4
-
8
-
None
-
b70
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8098780 | emb-9 | Hannes Wallnoefer | P4 | Resolved | Fixed | team |
If Nashorn evaluates a script that only contains function declarations it returns the last declared function as return value. This is against ECMAScript 5.1 section 14 which says that evaluation of a function declaration should not return a value.
http://es5.github.io/#x14
We probably introduced this behaviour because Rhino has the same bug, and people have been using this to obtain a reference to a function evaluated in a script.
One possible way to fix this while still allowing functions to be returned from script evaluation is to only return anonymous function statements (a Nashorn extension).
http://es5.github.io/#x14
We probably introduced this behaviour because Rhino has the same bug, and people have been using this to obtain a reference to a function evaluated in a script.
One possible way to fix this while still allowing functions to be returned from script evaluation is to only return anonymous function statements (a Nashorn extension).
- backported by
-
JDK-8098780 Script evaluation should not return last function declaration
-
- Resolved
-