Question on arrow function - if it is a bug or intentional in the spec ?
# Allen Wirfs-Brock (12 years ago)
The basic idea was that the parameters and body scope of a function are treated as a single "name space" where duplicate definitions are not allowed. Except that multiple var (and function) definitions are not considered duplicate definitions. For example:
function () {
let x;
var x; //illegal redefinition
}
function (x) {
let x; //illegal redefinition
}
function () {
var x;
var x;// allowed
}
function (x) {
var x; //allowed
}
Regular function formal parameter bindings are considered to be var-like and hence only the LexciallyDeclaredNames (let-like) restriction applies to them. The VarDeclaredNames restriction is there for ArrayParameters based upopn the understanding that they were going to be considered let-like declarations.
But, this might all change as we try to get final consensus on parameter scoping and ArrayParameter semantics
According to 14.2.1, the following arrow function expression should produce an early error :
x => {var x;}
Here is the spec line that mandates this rule. While this scenario is allowed in the regular functions (even in strict mode), I would like to understand the rationale behind this specific rule in arrow functions. Can someone shed some light on this ?