Bug 171041

Summary: We incorrectly throw a syntax error when declaring a top level for-loop iteration variable the same as a parameter
Product: WebKit Reporter: Rob Stutton <rob>
Component: JavaScriptCoreAssignee: Saam Barati <sbarati>
Status: RESOLVED FIXED    
Severity: Normal CC: ashwinkumar9944, benjamin, buildbot, commit-queue, fpizlo, ggaren, gskachkov, jfbastien, joepeck, keith_miller, mark.lam, msaboff, pkoszulinski, sbarati, ticaiolima, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: macOS 10.12   
Attachments:
Description Flags
patch
none
patch none

Description Rob Stutton 2017-04-19 22:17:54 PDT
I wouldn't write code like this (below) myself, but it was emitted by the minifier and so my app doesn't work in Safari, or Safari TP.
The code looks legal to me ...

let e = e => {
    console.log(e);
    for (let e of [1, 2, 3]) // Cannot declare a let variable twice: 'e'.
        console.log(e);
};
Comment 1 Saam Barati 2017-04-21 15:04:24 PDT
(In reply to Rob Stutton from comment #0)
> I wouldn't write code like this (below) myself, but it was emitted by the
> minifier and so my app doesn't work in Safari, or Safari TP.
> The code looks legal to me ...
> 
> let e = e => {
>     console.log(e);
>     for (let e of [1, 2, 3]) // Cannot declare a let variable twice: 'e'.
>         console.log(e);
> };

Yeah this looks like it should not be a syntax error, however, I think this should be:
```
let x = (e) => { let e; }
```

I bet the code that ensures that the above is a syntax error is kicking in when it shouldn't be.
Comment 2 Radar WebKit Bug Importer 2017-05-09 12:15:22 PDT
<rdar://problem/32082516>
Comment 3 Saam Barati 2017-05-21 15:10:04 PDT
Created attachment 310818 [details]
patch
Comment 4 Build Bot 2017-05-21 15:13:02 PDT
Attachment 310818 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/ChangeLog:13:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:20:  Line contains tab character.  [whitespace/tab] [5]
Total errors found: 2 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Saam Barati 2017-05-21 15:19:51 PDT
Created attachment 310819 [details]
patch
Comment 6 Yusuke Suzuki 2017-05-21 22:04:44 PDT
Comment on attachment 310819 [details]
patch

r=me
Comment 7 WebKit Commit Bot 2017-05-21 22:47:36 PDT
Comment on attachment 310819 [details]
patch

Clearing flags on attachment: 310819

Committed r217200: <http://trac.webkit.org/changeset/217200>
Comment 8 WebKit Commit Bot 2017-05-21 22:47:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Piotrek KoszuliƄski (Reinmar) 2017-09-05 02:18:01 PDT
How can this patch be not released yet (in a stable channel)? Since May? It will cause most of apps written in minified ES6 to fail.