Note 30.b of FunctionDeclarationInstantiation says:
Non-strict functions use a separate Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record.
I'm not sure I understand why a separate lexical environment (LE) is needed to determine if this top-level-let / eval-var conflict exists. Why can't we keep the caller function's LE and variable environment (VE) the same and then when it comes time to perform the eval call, use
varEnv.HasLexicalDeclaration(name) (as in step 3.a.i.1 of EvalDeclarationInstantiation) to resolve any conflict instead of the loop in step 3.d?
Also, when this new LE is created, why is its
outer property set to the function's variable environment (see step 30.b of FunctionDeclarationInstantiation)?