Skip to content

Commit

Permalink
Normative: Create global properties for sloppy function hosting as vars
Browse files Browse the repository at this point in the history
This patch removes a case where a synthetic *undefined* was visible
as a result of legacy sloppy-mode function hoisting.

This patch addresses #753
  • Loading branch information
littledan authored and ljharb committed Apr 11, 2017
1 parent e4bfa86 commit caf89a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -40457,11 +40457,11 @@ <h1>Changes to GlobalDeclarationInstantiation</h1>
1. Let _F_ be StringValue of the |BindingIdentifier| of |FunctionDeclaration| _f_.
1. If replacing the |FunctionDeclaration| _f_ with a |VariableStatement| that has _F_ as a |BindingIdentifier| would not produce any Early Errors for _script_, then
1. If _envRec_.HasLexicalDeclaration(_F_) is *false*, then
1. Let _fnDefinable_ be ? _envRec_.CanDeclareGlobalFunction(_F_).
1. Let _fnDefinable_ be ? _envRec_.CanDeclareGlobalVar(_F_).
1. If _fnDefinable_ is *true*, then
1. NOTE: A var binding for _F_ is only instantiated here if it is neither a VarDeclaredName nor the name of another |FunctionDeclaration|.
1. If _declaredFunctionOrVarNames_ does not contain _F_, then
1. Perform ? _envRec_.CreateGlobalFunctionBinding(_F_, *undefined*, *false*).
1. Perform ? _envRec_.CreateGlobalVarBinding(_F_, *false*).
1. Append _F_ to _declaredFunctionOrVarNames_.
1. When the |FunctionDeclaration| _f_ is evaluated, perform the following steps in place of the |FunctionDeclaration| Evaluation algorithm provided in <emu-xref href="#sec-function-definitions-runtime-semantics-evaluation"></emu-xref>:
1. Let _genv_ be the running execution context's VariableEnvironment.
Expand Down Expand Up @@ -40495,15 +40495,15 @@ <h1>Changes to EvalDeclarationInstantiation</h1>
1. Let _thisLex_ be _thisLex_'s outer environment reference.
1. If _bindingExists_ is *false* and _varEnvRec_ is a global Environment Record, then
1. If _varEnvRec_.HasLexicalDeclaration(_F_) is *false*, then
1. Let _fnDefinable_ be ? _varEnvRec_.CanDeclareGlobalFunction(_F_).
1. Let _fnDefinable_ be ? _varEnvRec_.CanDeclareGlobalVar(_F_).
1. Else,
1. Let _fnDefinable_ be *false*.
1. Else,
1. Let _fnDefinable_ be *true*.
1. If _bindingExists_ is *false* and _fnDefinable_ is *true*, then
1. If _declaredFunctionOrVarNames_ does not contain _F_, then
1. If _varEnvRec_ is a global Environment Record, then
1. Perform ? _varEnvRec_.CreateGlobalFunctionBinding(_F_, *undefined*, *true*).
1. Perform ? _varEnvRec_.CreateGlobalVarBinding(_F_, *true*).
1. Else,
1. Let _bindingExists_ be _varEnvRec_.HasBinding(_F_).
1. If _bindingExists_ is *false*, then
Expand Down

0 comments on commit caf89a1

Please sign in to comment.