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

TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.) #6923

Open
TimWolla opened this Issue Nov 27, 2017 · 7 comments

Comments

Projects
None yet
6 participants
@TimWolla

TimWolla commented Nov 27, 2017

Choose one: bug report

The error message

TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)

is shown when transpiling the input code. node successfully executes the input code.

Input Code

async function foo() {
	(async function (number) {
		const tmp = number
	})
}

Babel/Babylon Configuration (.babelrc, package.json, cli command)

{ "presets": [ [ "@babel/env"
               , { "targets": { "browsers": [ "last 2 chrome versions"
                                            , "last 2 chromeandroid versions"
                                            , "firefox esr"
                                            , "last 2 firefox versions"
                                            , "edge >= 15"
                                            , "safari >= 11"
                                            ]
                              }
                 , "debug": true
                 }
               ]
             ]
}
{
  "dependencies": {
    "@babel/cli": "^7.0.0-beta.32",
    "@babel/core": "^7.0.0-beta.32",
    "@babel/preset-env": "^7.0.0-beta.32",
    "regenerator-runtime": "^0.11.0"
  }
}

Expected Behavior

The script is successfully transpiled.

Current Behavior

The given error message appears:

root@3f46f465fd04:/pwd# yarn run babel test.js
yarn run v1.3.2
warning package.json: No license field
$ /pwd/node_modules/.bin/babel test.js
@babel/preset-env: `DEBUG` option

Using targets:
{
  "chrome": "61",
  "edge": "15",
  "firefox": "52",
  "safari": "11"
}

Using modules transform: commonjs

Using plugins:
  transform-destructuring { "edge":"15", "firefox":"52" }
  transform-for-of { "firefox":"52" }
  transform-function-name { "edge":"15", "firefox":"52" }
  transform-literals { "firefox":"52" }
  transform-parameters { "firefox":"52" }
  transform-regenerator { "firefox":"52" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/pwd/node_modules/@babel/core/lib/transformation/file/file.js:209:12)
    at Scope.checkBlockScopedCollisions (/pwd/node_modules/@babel/traverse/lib/scope/index.js:295:27)
    at Scope.registerBinding (/pwd/node_modules/@babel/traverse/lib/scope/index.js:477:16)
    at Scope.registerDeclaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:396:14)
    at Object.Declaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:89:12)
    at NodePath._call (/pwd/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/pwd/node_modules/@babel/traverse/lib/path/context.js:38:17)
    at NodePath.visit (/pwd/node_modules/@babel/traverse/lib/path/context.js:95:12)
    at TraversalContext.visitQueue (/pwd/node_modules/@babel/traverse/lib/context.js:139:18)
    at TraversalContext.visitMultiple (/pwd/node_modules/@babel/traverse/lib/context.js:93:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Possible Solution

Context

It worked fine with babel-preset-env in version 1.5.2. It is broken with @babel/preset-env in version 7.0.0-beta.32.

Your Environment

software version(s)
Babel 7.0.0-beta.32 (@babel/core 7.0.0-beta.32)
Babylon
node v9.2.0
npm 5.5.1
Operating System Official node.js Docker container
@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Nov 27, 2017

Collaborator

Hey @TimWolla! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Collaborator

babel-bot commented Nov 27, 2017

Hey @TimWolla! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@TimWolla

This comment has been minimized.

Show comment
Hide comment
@TimWolla

TimWolla Nov 27, 2017

Updated initial issue to remove incorrect remark about transform-arrow-functions, apparently I had some older version of my testcase in my mind.

TimWolla commented Nov 27, 2017

Updated initial issue to remove incorrect remark about transform-arrow-functions, apparently I had some older version of my testcase in my mind.

@TimWolla

This comment has been minimized.

Show comment
Hide comment
@TimWolla

TimWolla Feb 12, 2018

@nicolo-ribaudo According to the commit (4887d81) the patch is contained in the v7.0.0-beta.40 tag. I tried again with beta 40, but still encounter this issue:

[timwolla@/t/test [1]]cat package.json .babelrc                                                                                                                                                             20:16:57
{
  "dependencies": {
    "@babel/cli": "^7.0.0-beta.40",
    "@babel/core": "^7.0.0-beta.40",
    "@babel/preset-env": "^7.0.0-beta.40",
    "regenerator-runtime": "^0.11.0"
  }
}
{ "presets": [ [ "@babel/env"
               , { "targets": { "browsers": [ "last 2 chrome versions"
                                            , "last 2 chromeandroid versions"
                                            , "firefox esr"
                                            , "last 2 firefox versions"
                                            , "edge >= 15"
                                            , "safari >= 11"
                                            ]
                              }
                 , "debug": true
                 }
               ]
             ]
}
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd -v /scratch/cache/yarn:/usr/local/share/.cache/yarn/v1 timwolla/node yarn install                                         20:17:01
yarn install v1.3.2
warning package.json: No license field
info No lockfile found.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 10.09s.
[timwolla@/t/test]cat test.js                                                                                                                                                                               20:17:16
async function foo() {
	(async function (number) {
		const tmp = number
	})
}
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd -v /scratch/cache/yarn:/usr/local/share/.cache/yarn/v1 timwolla/node yarn run babel test.js                               20:17:22
yarn run v1.3.2
warning package.json: No license field
$ /pwd/node_modules/.bin/babel test.js
@babel/preset-env: `DEBUG` option

Using targets:
{
  "chrome": "63",
  "edge": "15",
  "firefox": "52",
  "safari": "11"
}

Using modules transform: commonjs

Using plugins:
  transform-destructuring { "edge":"15", "firefox":"52" }
  transform-for-of { "firefox":"52" }
  transform-function-name { "edge":"15", "firefox":"52" }
  transform-literals { "firefox":"52" }
  transform-parameters { "firefox":"52" }
  transform-regenerator { "firefox":"52" }
  transform-dotall-regex { "edge":"15", "firefox":"52", "safari":"11" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/pwd/node_modules/@babel/core/lib/transformation/file/file.js:207:12)
    at Scope.checkBlockScopedCollisions (/pwd/node_modules/@babel/traverse/lib/scope/index.js:303:27)
    at Scope.registerBinding (/pwd/node_modules/@babel/traverse/lib/scope/index.js:485:16)
    at Scope.registerDeclaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:404:14)
    at Object.Declaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:89:12)
    at NodePath._call (/pwd/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/pwd/node_modules/@babel/traverse/lib/path/context.js:38:17)
    at NodePath.visit (/pwd/node_modules/@babel/traverse/lib/path/context.js:99:12)
    at TraversalContext.visitQueue (/pwd/node_modules/@babel/traverse/lib/context.js:135:18)
    at TraversalContext.visitMultiple (/pwd/node_modules/@babel/traverse/lib/context.js:89:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[timwolla@/t/test [1]]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd timwolla/node node --version                                                                                          20:17:29
v9.5.0
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd timwolla/node npm --version                                                                                               20:17:49
5.6.0

Did I do something wrong?

TimWolla commented Feb 12, 2018

@nicolo-ribaudo According to the commit (4887d81) the patch is contained in the v7.0.0-beta.40 tag. I tried again with beta 40, but still encounter this issue:

[timwolla@/t/test [1]]cat package.json .babelrc                                                                                                                                                             20:16:57
{
  "dependencies": {
    "@babel/cli": "^7.0.0-beta.40",
    "@babel/core": "^7.0.0-beta.40",
    "@babel/preset-env": "^7.0.0-beta.40",
    "regenerator-runtime": "^0.11.0"
  }
}
{ "presets": [ [ "@babel/env"
               , { "targets": { "browsers": [ "last 2 chrome versions"
                                            , "last 2 chromeandroid versions"
                                            , "firefox esr"
                                            , "last 2 firefox versions"
                                            , "edge >= 15"
                                            , "safari >= 11"
                                            ]
                              }
                 , "debug": true
                 }
               ]
             ]
}
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd -v /scratch/cache/yarn:/usr/local/share/.cache/yarn/v1 timwolla/node yarn install                                         20:17:01
yarn install v1.3.2
warning package.json: No license field
info No lockfile found.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 10.09s.
[timwolla@/t/test]cat test.js                                                                                                                                                                               20:17:16
async function foo() {
	(async function (number) {
		const tmp = number
	})
}
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd -v /scratch/cache/yarn:/usr/local/share/.cache/yarn/v1 timwolla/node yarn run babel test.js                               20:17:22
yarn run v1.3.2
warning package.json: No license field
$ /pwd/node_modules/.bin/babel test.js
@babel/preset-env: `DEBUG` option

Using targets:
{
  "chrome": "63",
  "edge": "15",
  "firefox": "52",
  "safari": "11"
}

Using modules transform: commonjs

Using plugins:
  transform-destructuring { "edge":"15", "firefox":"52" }
  transform-for-of { "firefox":"52" }
  transform-function-name { "edge":"15", "firefox":"52" }
  transform-literals { "firefox":"52" }
  transform-parameters { "firefox":"52" }
  transform-regenerator { "firefox":"52" }
  transform-dotall-regex { "edge":"15", "firefox":"52", "safari":"11" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
TypeError: test.js: Duplicate declaration "tmp" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/pwd/node_modules/@babel/core/lib/transformation/file/file.js:207:12)
    at Scope.checkBlockScopedCollisions (/pwd/node_modules/@babel/traverse/lib/scope/index.js:303:27)
    at Scope.registerBinding (/pwd/node_modules/@babel/traverse/lib/scope/index.js:485:16)
    at Scope.registerDeclaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:404:14)
    at Object.Declaration (/pwd/node_modules/@babel/traverse/lib/scope/index.js:89:12)
    at NodePath._call (/pwd/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/pwd/node_modules/@babel/traverse/lib/path/context.js:38:17)
    at NodePath.visit (/pwd/node_modules/@babel/traverse/lib/path/context.js:99:12)
    at TraversalContext.visitQueue (/pwd/node_modules/@babel/traverse/lib/context.js:135:18)
    at TraversalContext.visitMultiple (/pwd/node_modules/@babel/traverse/lib/context.js:89:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[timwolla@/t/test [1]]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd timwolla/node node --version                                                                                          20:17:29
v9.5.0
[timwolla@/t/test]docker run -it --rm -v (pwd):(pwd) -v (pwd):/pwd --workdir /pwd timwolla/node npm --version                                                                                               20:17:49
5.6.0

Did I do something wrong?

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Feb 13, 2018

Member

I will check later

Member

nicolo-ribaudo commented Feb 13, 2018

I will check later

@retyui

This comment has been minimized.

Show comment
Hide comment
@retyui

retyui Feb 14, 2018

@nicolo-ribaudo check please this error!

retyui commented Feb 14, 2018

@nicolo-ribaudo check please this error!

@nicolo-ribaudo nicolo-ribaudo self-assigned this Feb 14, 2018

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo May 16, 2018

Member

Reduced test case:

babel.transformSync(
  `
  async function foo() {
    (async function (number) {
      const tmp = number
    })
  }
`,
  {
    configFile: false,
    plugins: [load("plugin-transform-regenerator")],
  }
).code;
Member

nicolo-ribaudo commented May 16, 2018

Reduced test case:

babel.transformSync(
  `
  async function foo() {
    (async function (number) {
      const tmp = number
    })
  }
`,
  {
    configFile: false,
    plugins: [load("plugin-transform-regenerator")],
  }
).code;

@nicolo-ribaudo nicolo-ribaudo referenced a pull request that will close this issue May 16, 2018

Open

Update binginds after using path#replaceWith #7953

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment