question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot redeclare let variable in Safari

See original GitHub issue

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):

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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
btmillscommented, 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.

0reactions
tinovyatkincommented, 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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found