Generator issue: exceptions while initializing arguments
Dmitry Soshnikov
dmitry.soshnikov at gmail.com
Tue Sep 11 11:43:11 PDT 2012
On Tue, Sep 11, 2012 at 1:36 AM, Brendan Eich <brendan at mozilla.com> wrote:
> Dmitry Soshnikov wrote:
>
>> var FOO = 42;
>> function bar(x, y = FOO + z) { var z = 10; } // Error .. ?
>>
>
> Translating to JS as it is:
>
> var FOO = 42;
> function bar(x, y) {
> if (y === void 0) y = FOO + z;
> var z = 10;
> }
>
> No error expected, undefined hoisted z used in FOO + z resulting in y
> defaulting to NaN if y is not passed or given actual undefined value in a
> call.
>
>
Ah, OK, so then it's just evals as a casual local var/parameter (in
activation + bar.[[Scope]]) and that's it. And there probably will not be a
confusion.
Yes, this one may be better than just outer scope. Sorry, I thought about
some more complicated stuff (first outer, then inner). If this is the same
as a casual local var resolutions, then it's OK.
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120911/62a19acb/attachment.html>
More information about the es-discuss
mailing list