<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:sbarati&#64;apple.com" title="Saam Barati &lt;sbarati&#64;apple.com&gt;"> <span class="fn">Saam Barati</span></a>
</span> changed
              <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>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #302079 Flags</td>
           <td>review?
           </td>
           <td>review-
           </td>
         </tr></table>
      <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#c54">Comment # 54</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:sbarati&#64;apple.com" title="Saam Barati &lt;sbarati&#64;apple.com&gt;"> <span class="fn">Saam Barati</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=302079&amp;action=diff" name="attach_302079" title="Patch">attachment 302079</a> <a href="attachment.cgi?id=302079&amp;action=edit" title="Patch">[details]</a></span>
Patch

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

Some comments below. Mostly looks good, but I think there might be a few bugs.

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:18
&gt; +        we do not bind. In simple patch should lead to following 
&gt; +        behavior:</span >

&quot;In simple patch should lead to following behavior&quot; =&gt; &quot;This patch leads to the following behavior&quot;

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:29
&gt; +        boo();</span >

foo

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:51
&gt; +        </span >

you need a call here to match the other ones. Or you can just remove the calls from your example, I think it's clear what you mean without them.

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:59
&gt; +        function bas() {
&gt; +            {
&gt; +                 let boo = 10;
&gt; +                 eval(' { function boo() {} } ');
&gt; +                 print(boo); // 10
&gt; +            }
&gt; +            print(boo); //Reference Error
&gt; +        }</span >

Can you open a bug to fix this issue:
(This exists both for eval and normal function hoisting):
eval(&quot; { let foo; {function foo(){} } }&quot;);

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:72
&gt; +        or return undefined if variable can be binded there.</span >

can =&gt; can't

<span class="quote">&gt; Source/JavaScriptCore/ChangeLog:75
&gt; +        that is not covered by this path, and will be fixed in </span >

Typo: path =&gt; patch

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:767
&gt; +    for (FunctionMetadataNode* function : evalNode-&gt;functionStack())
&gt; +        m_codeBlock-&gt;addFunctionDecl(makeFunction(function));</span >

Doesn't this still cause us to unconditionally create the binding?

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:770
&gt; +    // unsigned numVariables = varDeclarations.size();</span >

Please remove.

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:779
&gt; +        if (!entry.value.isFunction())
&gt; +            variables.append(Identifier::fromUid(m_vm, entry.key.get()));
&gt; +        else
&gt; +            hoistedFunctions.append(Identifier::fromUid(m_vm, entry.key.get()));</span >

This looks wrong to me and looks like it'd cause weird behavior for strict mode. I think you want to check if it's a hoisting candidate instead.

<span class="quote">&gt; Source/JavaScriptCore/interpreter/Interpreter.cpp:1076
&gt; +    if ((numVariables || numFunctions || numHoistedFunctions) &amp;&amp; eval-&gt;isStrictMode()) {</span >

I don't think you want this number to be &gt; 0 in strict mode.

<span class="quote">&gt; Source/JavaScriptCore/runtime/CommonSlowPaths.cpp:827
&gt; +SLOW_PATH_DECL(slow_path_is_var_scope)</span >

Please remove.

<span class="quote">&gt; Source/JavaScriptCore/runtime/JSScope.cpp:220
&gt; +ALWAYS_INLINE JSObject* JSScope::resolve(ExecState* exec, JSScope* scope, const Identifier&amp; ident, FinishResolveEarlierFunctor predicate, bool doNotCountWithScope)</span >

Nit: I'd just make doNoutCountWithScope  a templatized variable.</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>