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

Error when running exports transformation with shadowed variable #55

Open
daveisfera opened this issue May 2, 2019 · 4 comments
Open

Comments

@daveisfera
Copy link

This the stacktrace:

 ERR test.js Transformation error (Identifier 'ids' has already been declared (3:12))
SyntaxError: Identifier 'ids' has already been declared (3:12)
    at Object.raise (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:6322:17)
    at ScopeHandler.checkRedeclarationInScope (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:3754:12)
    at ScopeHandler.declareName (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:3720:12)
    at Object.checkLVal (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:8006:22)
    at Object.checkLVal (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:373:15)
    at Object.parseVarId (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:10441:10)
    at Object.parseVar (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:10412:12)
    at Object.parseVarStatement (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:10234:10)
    at Object.parseStatementContent (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:9830:21)
    at Object.parseStatement (/Users/dlj/.config/yarn/global/node_modules/@babel/parser/lib/index.js:9763:17)

And here's a simple file that demonstrates the issue:

class Repeated {
    doSomething(ids) { 
        let ids = { ids: ids.toString() };
        return ids;
    }
}
@xjamundx
Copy link
Contributor

xjamundx commented May 8, 2019

Thanks for the report. Which transform are you using?

@xjamundx
Copy link
Contributor

xjamundx commented May 8, 2019

FYI this is legitimately a syntax error:

function a(b) { let b; }

so probably we'll need to detect these cases somehow... 🤔

@xjamundx
Copy link
Contributor

xjamundx commented May 8, 2019

Oh was this var to let?

@dave-nm
Copy link

dave-nm commented May 8, 2019

It was the exports transformation.

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

No branches or pull requests

3 participants