<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES2016] Allow assignment in for-in head in not-strict mode"
   href="https://bugs.webkit.org/show_bug.cgi?id=160955#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES2016] Allow assignment in for-in head in not-strict mode"
   href="https://bugs.webkit.org/show_bug.cgi?id=160955">bug 160955</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>(In reply to <a href="show_bug.cgi?id=160955#c11">comment #11</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=286712&amp;action=diff" name="attach_286712" title="Patch">attachment 286712</a> <a href="attachment.cgi?id=286712&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=286712&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=286712&amp;action=review</a>
&gt; 
&gt; r=me with one request:
&gt; 
&gt; Can you see what should be done for the following type of programs:
&gt; ```
&gt; function foo() {
&gt;     {
&gt;         let x = 50;
&gt;         for (var x = 25 in {}) { }
&gt;         // what is x here?
&gt;     }
&gt;     // and what is x here?
&gt; }
&gt; foo();
&gt; 
&gt; and
&gt; 
&gt; function foo() {
&gt;     {
&gt;         const x = 50;
&gt;         for (var x = 25 in {}) { }
&gt;        // Should we throw a const assignment error?
&gt;     }
&gt; }
&gt; foo();
&gt; ```
&gt; Currently, both Firefox and Chrome throw syntax errors for these programs.
&gt; However, I suspect that's not the correct behavior as defined by the spec.
&gt; If it is, we should also throw a syntax error. If it isn't, we should make
&gt; sure we do the right thing. I suspect that in the first example,
&gt; in the &quot;let x&quot; scope, x should be 25. In the &quot;var&quot; scope of the function, I
&gt; suspect x should be undefined. But who knows.
&gt; 
&gt; &gt; Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:2560
&gt; &gt; +void ForInNode::emitResolveVariable(BytecodeGenerator&amp; generator, RegisterID* propertyName, const Identifier&amp; ident)
&gt; 
&gt; Suggestion: An alternative to defining a method is you can just use a local
&gt; lambda inside the ::emitLoopHeader that does this.</span >

Hmm, it is good question.
I think it should behave in the same way as work without for..in, and this annex to spec should not modify this behavior so it currently work in this way
function foo() {
    {
         let x = 50;
         var x = 25;
         debug(x); // 25
     }
     debug(x); // undefined
}
foo();
//////////////////////
function foo() {
    {
         const x = 50;
         var x = 25;
         debug(x); // Syntax Error
     }
     debug(x); // undefined
}
foo();
with for..in it works in the same way.
Should I add tests for this cases?</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>