Real World Func Decl in Block Scope Breakages

Brandon Benvie brandon at brandonbenvie.com
Wed Dec 26 18:07:51 PST 2012


if I run this code in the tools > web developer > web console, I get a
result of undefined and no error
`if (false) { function x(){ console.log('worked') } } x();`


On Wed, Dec 26, 2012 at 9:06 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Brandon Benvie wrote:
>
>> My tests basically indicate what you said, but with a minor distinction.
>> They don't fail outright, as in throw an error. They just fail silently. As
>> in, it's ok to call the identifier, but it's not going to do anything.
>>
>
> No, something else is wrong. Can you show such a (reduced, I take it)
> testcase?
>
>
>  This is a curious Schrodinger's cat kind of intermediate state, where it
>> doesn't succeed in doing what it was asked, but doesn't throw an error
>> either, which in JS terms means it air-quotes succeeded but didn't really.
>>
>
> SpiderMonkey's function-in-block does not create any such magic error-free
> behavior. I don't know what you're seeing, but it's not what I saw at a
> glance, and not what SpiderMonkey implements for f-i-b.
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121226/8acc8a8b/attachment.html>


More information about the es-discuss mailing list