Cannot redeclare let variable in Safari
See original GitHub issueAfter 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):
function a(e) {
let e = 1;
console.log(e);
}
a(2);
// Real life minify result:
function Ge(e, t) {
const n = e.toLowerCase(),
a = n.split(/\s+/),
r = [];
for (let e = 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(''));
return r.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)?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Safari - SyntaxError: Cannot declare a let variable twice
Definitely seems like a Safari bug to me. The let in the loop should be running in its own iteration-specific environment. – loganfsmyth....
Read more >let - JavaScript - MDN Web Docs
The let declaration declares a block-scoped local variable, optionally initializing it to a value.
Read more >Misleading Explanation of let variables - JavaScript
You can not redeclare a variable that is declared using let . Declaring two variables in two different scopes is not the same...
Read more >Cannot redeclare block-scoped variable? How to resolve
Because, the let keyword is block scoped and unlike var, it can not be re-declared or reassigned within the same block. After Transpiling...
Read more >Share variable data through View Controllers - Apple Developer
I need to share the data of a String variable between two view controllers. ... like let firstVC = FirstViewController() would not work...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We hit this bug at work. I’ve put together what I hope is a successful workaround and filed a PR: #567.
@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?