Bug 171041 - We incorrectly throw a syntax error when declaring a top level for-loop iteration variable the same as a parameter
Summary: We incorrectly throw a syntax error when declaring a top level for-loop itera...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified macOS 10.12
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-04-19 22:17 PDT by Rob Stutton
Modified: 2018-02-13 17:24 PST (History)
17 users (show)

See Also:


Attachments
patch (11.09 KB, patch)
2017-05-21 15:10 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch (11.09 KB, patch)
2017-05-21 15:19 PDT, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.
Comment 10 R_ashwin 2017-10-04 02:01:30 PDT Comment hidden (spam)