what is the bug in this?

A. Sundararajan sundararajan.athijegannathan at oracle.com
Wed Oct 30 06:31:57 PDT 2013


np! Thanks for the background.

-Sundar

On Wednesday 30 October 2013 06:49 PM, André Bargull wrote:
> On 10/30/2013 1:43 PM, A. Sundararajan wrote:
>> Hi,
>>
>> In one of the lists you submitted, the following is mentioned:
>>
>> jjs> Function("return function() { eval(''); return anonymous; }")
>>
>> Expected: throws ReferenceError
>> Actual: returns function
>>
>>
>> Why is ReferenceError expected in the above? Will you please explain? 
>> I checked other impls too - none throw error (just like nashorn). Am 
>> I missing something?
>>
>> -Sundar
>>
>
> Hmm, good question. Most likely I made a copy-paste error and then 
> came to the wrong conclusion.
>
> By the looks of the test case I was testing for the .name property of 
> functions created by the Function() constructor. In JavaScriptCore and 
> SpiderMonkey, `Function("").name` is "anonymous" [1], but that must 
> not create a binding for "anonymous", that means `Function("return 
> function() { eval(''); return anonymous; }")()()` must throw a 
> ReferenceError. Possibly I copy-pasted that code to the nashorn shell 
> without the trailing `()()` parentheses and then noticed no 
> ReferenceError was thrown and by that came to the wrong conclusion 
> that nashorn has the same binding bug as [2].
>
> Sorry for the confusion!
>
> - André
>
>
> [1] 
> http://wiki.ecmascript.org/doku.php?id=strawman:name_property_of_functions
> [2] https://bugzilla.mozilla.org/show_bug.cgi?id=636635



More information about the nashorn-dev mailing list