<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6]. Implement Annex B.3.3 function hoisting rules for eval"
   href="https://bugs.webkit.org/show_bug.cgi?id=163208#c48">Comment # 48</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6]. Implement Annex B.3.3 function hoisting rules for eval"
   href="https://bugs.webkit.org/show_bug.cgi?id=163208">bug 163208</a>
              from <span class="vcard"><a class="email" href="mailto:gskachkov&#64;gmail.com" title="GSkachkov &lt;gskachkov&#64;gmail.com&gt;"> <span class="fn">GSkachkov</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=301300&amp;action=diff" name="attach_301300" title="Patch">attachment 301300</a> <a href="attachment.cgi?id=301300&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=301300&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=301300&amp;action=review</a>

<span class="quote">&gt;&gt; Source/JavaScriptCore/ChangeLog:24
&gt;&gt; +        has var type we bind function there
&gt; 
&gt; This code I believe is slightly wrong w.r.t the specification.
&gt; The behavior we want is not to always create the binding and then to conditionally bind, but rather, to conditionally create the binding, and to bind to it unconditionally if we created it.
&gt; 
&gt; For example, I checked out your code, and this function won't throw an exception. It'll return undefined. I believe the desired behavior is to throw a ReferenceError:
&gt; 
&gt; ```
&gt; function foo() {
&gt;     {
&gt;         let f;
&gt;         eval(&quot;{ function f() { return 20; } }&quot;);
&gt;     }
&gt;     return f;
&gt; }
&gt; foo();
&gt; ```
&gt; 
&gt; That said, I think this patch still does the majority of the work to implementing what I said above. To get the behavior I said above, I think all you'll need to do is change code inside Interpreter.cpp when running eval code.
&gt; I think it's best at this point to do this fix as a follow up.</span >

Yeah, my bad, I see my patch is only focus to conditionally bind.

<span class="quote">&gt;&gt; Source/JavaScriptCore/runtime/JSScope.cpp:248
&gt;&gt; +            continue;
&gt; 
&gt; What does the spec say here? Does it say to skip over `with`? Or does it say to iterate the scope chain during `eval` instantiation.
&gt; This is important because the hasProperty below is observable for `with` scopes.
&gt; 
&gt; Also, thinking about this patch more, I think the resolve_closest_or_var and is_var_scope_type could be fully answerable during bytecode linking if the spec behavior is to skip over `with` scopes.
&gt; So we need to find out if we indeed skip `with` scopes, or we somehow interact with them when creating the eval.</span >

According to spec B.3.3.3.1.d.ii.4 we do loop over EnvironmentRecord, and  only B.3.3.3.1.d.ii.4.b we do check 'If thisEnvRec is not an _object_ Environment Record'
and then in B.3.3.3.1.d.ii.4.b.i we do check hasBinding for found object. So how I can understand we need to skip 'with' scope</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>