Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate declaration in nested function that has a let variable with same name as function. #226

Closed
aickin opened this issue Oct 26, 2016 · 8 comments
Labels
bug Confirmed bug

Comments

@aickin
Copy link

aickin commented Oct 26, 2016

Hey babili awesome folks. Thanks for all your work!

I think I've found a bug where babili throws a "Duplicate declaration" error when I have a nested named function whose name is the same as a let variable inside the function.

Here's a reduced repro case:

http://babeljs.io/repl/#?babili=true&evaluate=true&lineWrap=false&presets=&code=var%20sayHello%20%20%3D%20function(name)%20%7B%0A%20%20'use%20strict'%3B%0A%20%20%0A%20%20function%20foo(callback2)%20%7B%0A%20%20%20%20let%20foo%20%3D%20callback2()%3B%0A%20%20%20%20return%20%22hello%2C%20%22%20%2B%20foo%3B%0A%20%20%7D%0A%20%20%0A%20%20return%20foo(()%3D%3Ename)%3B%0A%7D&experimental=true&loose=false&spec=false&playground=false

This code snippet runs fine in latest Chrome, so I'm pretty sure it's valid ES2015. Let me know if you need any more info, and thanks again!

@boopathi boopathi added the bug Confirmed bug label Oct 27, 2016
@boopathi
Copy link
Member

Thanks!

Hmm.. This is a tricky one.

@boopathi
Copy link
Member

boopathi commented Feb 3, 2017

This is not a problem anymore in latest babili.

@boopathi boopathi closed this as completed Feb 3, 2017
@Nantris
Copy link

Nantris commented Sep 3, 2017

@boopathi Using babili 0.1.2 I still got this error. Had to go and change variable names and it seems to work now. Not 100% sure, still waiting for it to process.

@vigneshshanmugam
Copy link
Member

vigneshshanmugam commented Sep 4, 2017

@slapbox can you give an sample code for the issue?

@Nantris
Copy link

Nantris commented Sep 4, 2017

export function dateWithOffset() {
  let dateWithOffset;
  const date = new Date();
 	dateWithOffset = null;
  if (global.ntpOffset) {
    const dateMilliseconds = date.getTime() + global.ntpOffset;
    dateWithOffset = new Date(dateMilliseconds);
  } else {
    dateWithOffset = date;
  }
  return dateWithOffset;
}

@vigneshshanmugam
Copy link
Member

I tried with the 0.2.0 version and I cannot reproduce the error with your sample code.

@Nantris
Copy link

Nantris commented Sep 5, 2017

Ah I didn't realize there was a 0.2.0 under the rename. I'm still on 0.1.2. I assume the issue is resolved. I'll try 0.2.0 later and if I find otherwise I'll update you. Thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

5 participants