What about a closure in the param list that refers to a param later in the list?
function foo(bar = function() { return x; }, x = 1) {
return bar();
}
foo(); // throws or 1?
I'm inclined to think that's fine because it's equivalent to:
{
var bar = function() {
return x;
}
let x = 1;
bar();
}
But then I'm thinking the following should throw?
function foo(bar = function() { return x; }, x = bar()) {
return x;
}
foo(); // throws or undefined?
Finally what about this:
function foo(bar = function(y = x) { return y; }, x = 1) {
return bar();
}
foo(); // throws or is 1?
With regards to transpiling it seems like TDZ has to be a static check.