You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to babili 0.1.2 following error appears in Safari 10.1 (running ES6 native): SyntaxError: Cannot declare a let variable twice: 'e'.. It happens on fragments like this (after minify I have a lot of this):
functiona(e){lete=1;console.log(e);}a(2);// Real life minify result:functionGe(e,t){constn=e.toLowerCase(),a=n.split(/\s+/),r=[];for(lete=0,n=0;n<t&&e<a.length;n+=a[e].length,e++)r.push(a[e].split('').map((e)=>e.normalize('NFKD').charAt(0)).filter((e)=>/[A-z]/.test(e)).join(''));returnr.join('-');}
and it seems for me that Safari counts function parameters as declared by let. Neither Chrome, Firefox or Edge have such problem. Is there any workaround apart of switching off minify (as I'm forced to do now)?
Reacted by Joe Fitzgerald, Nathan Fritz, nik and Vikash Kumar
The source code is huge (I pass babili over rollup bundle with mixed es6 / es3 content), and it produces a lot of that results, but all times with e letter, not sure if it make sense.
Safari's block scoping implementation is by far the buggiest. There is a lot of valid code that crashes in safari, both at parse and run time.
The only reason I haven't reported is because I haven't been able to get it to reproduce in non-proprietary code (or with bundles smaller than "entire work website codebase"), but hopefully this bug gets Safari to look better into their block scoping implementation.
Activity
boopathi commentedon May 26, 2017
Thanks. This looks like is a bug. It shouldn't be reused with fn param in the same scope.
Can you give the source code and config of how you used babili that reproduces this bug ?
I'm not able to reproduce with a simple function.
gives
tinovyatkin commentedon May 26, 2017
The source code is huge (I pass babili over rollup bundle with mixed es6 / es3 content), and it produces a lot of that results, but all times with
eletter, not sure if it make sense.Config is below:
the first function is just an example, the second function is output of this:
boopathi commentedon May 26, 2017
I think it is a safari bug.
is valid ES6. The
letbinds to the for loop and not the function. I'm really not sure how to work around this bug.kzc commentedon May 26, 2017
https://bugs.webkit.org/show_bug.cgi?id=171041
tinovyatkin commentedon May 27, 2017
Nobody will write such code in real life, why minify should? Just take next letter if this is used for function param already?
tinovyatkin commentedon May 27, 2017
as per https://kangax.github.io/compat-table/es6/ Safari 10.1 is the browser with most complete ES6 support. If it has a bug, it's better to adopt for it, instead of fighting with a bleeding edge browser.
Jessidhia commentedon May 28, 2017
Safari's block scoping implementation is by far the buggiest. There is a lot of valid code that crashes in safari, both at parse and run time.
The only reason I haven't reported is because I haven't been able to get it to reproduce in non-proprietary code (or with bundles smaller than "entire work website codebase"), but hopefully this bug gets Safari to look better into their block scoping implementation.
boopathi commentedon May 31, 2017
FYI, https://webkit.org/blog/7622/release-notes-for-safari-technology-preview-31/ under
JavaScriptthis bug is fixed in Safari.tinovyatkin commentedon May 31, 2017
@boopathi That's great, but the bug is already in several shipped versions, so, I think it must be avoided for a next couple of years... No fix?
Add workaround for Safari for loop lexical scope bug
Add workaround for Safari for loop lexical scope bug
Add workaround for Safari for loop lexical scope bug
btmills commentedon Jun 6, 2017
We hit this bug at work. I've put together what I hope is a successful workaround and filed a PR: #567.
Add workaround for Safari for loop lexical scope bug (#567)