Clarification regarding "top level" arrow functions and "this"/"arguments"
Brendan Eich
brendan at mozilla.org
Wed Jan 21 10:21:14 PST 2015
Felix Kling wrote:
> [Section
> 14.2.17](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-arrow-function-definitions-runtime-semantics-evaluation)
> says
>
>> Any reference to `arguments`, `super`, or `this` within an
>> *ArrowFunction* are resolved to their bindings in the lexically
>> enclosing function.
>
> However, what if there is no enclosing function? Shouldn't this say
> "enclosing environment"?
Good catch, probably best to file a bug at this point:
http://bugs.ecmascript.org/
> If yes, what would be the expected behavior of an arrow function that
> references `this` and `arguments`?
> I assume in case of `this`, it would just resolve to the *thisBinding*
> of the environment (if there is one). Since there is no `arguments`
> binding (by default) I assume accessing `arguments` would throw a
> reference error.
>
> Is my understanding correct?
I think so, but SpiderMonkey has a bug, so it's hard to test that
implementation.
https://bugzilla.mozilla.org/show_bug.cgi?id=889158
/be
More information about the es-discuss
mailing list