archives

« Bugzilla Issues Index

#221 — Should hoisted functions be visible to parameter default value initializers?


Consider

function foo(p = func()) {
funtion func() {return 5}
return p
}



Is this legal or not?

In the November 7, 2011 draft they are, beause inner functions are initiated and marked as initialized before the surrounding function's formal parameters are initialized. To change this would take some restructuring of specification algorithms.

Allen


At the Nov 2011 meeting, the consensus was that local declarations (including functions) are not visible to PDV expressions. Also, that there is a temporal dead zone for PDV expression reference to parameter names defined in the same parameter list.

This is implemented in the REv 5 draft.