[Webkit-unassigned] [Bug 160955] [ES2016] Allow assignment in for-in head in not-strict mode

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 23 09:29:42 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=160955

Saam Barati <sbarati at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #286712|review?                     |review+
              Flags|                            |

--- Comment #11 from Saam Barati <sbarati at apple.com> ---
Comment on attachment 286712
  --> https://bugs.webkit.org/attachment.cgi?id=286712
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=286712&action=review

r=me with one request:

Can you see what should be done for the following type of programs:
```
function foo() {
    {
        let x = 50;
        for (var x = 25 in {}) { }
        // what is x here?
    }
    // and what is x here?
}
foo();

and

function foo() {
    {
        const x = 50;
        for (var x = 25 in {}) { }
       // Should we throw a const assignment error?
    }
}
foo();
```
Currently, both Firefox and Chrome throw syntax errors for these programs. However, I suspect that's not the correct behavior as defined by the spec.
If it is, we should also throw a syntax error. If it isn't, we should make sure we do the right thing. I suspect that in the first example,
in the "let x" scope, x should be 25. In the "var" scope of the function, I suspect x should be undefined. But who knows.

> Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:2560
> +void ForInNode::emitResolveVariable(BytecodeGenerator& generator, RegisterID* propertyName, const Identifier& ident)

Suggestion: An alternative to defining a method is you can just use a local lambda inside the ::emitLoopHeader that does this.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160823/ff7e09bc/attachment.html>


More information about the webkit-unassigned mailing list