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

babel-traverse Scope.rename bad case #11591

Closed
1 task done
yulanggong opened this issue May 21, 2020 · 1 comment · Fixed by #11595
Closed
1 task done

babel-traverse Scope.rename bad case #11591

yulanggong opened this issue May 21, 2020 · 1 comment · Fixed by #11595
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@yulanggong
Copy link
Contributor

yulanggong commented May 21, 2020

Bug Report

I add a test case here:
yulanggong@0dfff88

Input Code

function test(b) {
  var a = b + 1,
      a = a + 1,
      a = a + 1;

  return a;
}

Plugin Code

module.exports = function() {
  return {
    visitor: {
      Scope(path) {
        path.scope.rename("a", "_a");
      }
    }
  };
}

Expected Result

function test(b) {
  var _a = b + 1,
      _a = _a + 1,
      _a = _a + 1;

  return _a;
}

Current Result

function test(b) {
  var _a = b + 1,
      a = _a + 1,
      _a = _a + 1;

  return _a;
}

Diff

- Expected
+ Received

  function test(b) {
    var _a = b + 1,
-       _a = _a + 1,
+       a = _a + 1,
        _a = _a + 1;

    return _a;
  }

Environment

System:
    OS: macOS 10.15.4
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v10.16.3/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v10.16.3/bin/npm
  Monorepos:
    Lerna: 3.19.0
  npmPackages:
    @babel/cli: ^7.8.4 => 7.8.4
    @babel/core: ^7.9.6 => 7.9.6
    @babel/eslint-plugin-development: ^1.0.1 => 1.0.1
    @babel/plugin-proposal-class-properties: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-dynamic-import: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-export-namespace-from: ^7.8.3 => 7.8.3
    @babel/plugin-proposal-object-rest-spread: ^7.9.6 => 7.9.6
    @babel/plugin-transform-flow-strip-types: ^7.9.0 => 7.9.0
    @babel/plugin-transform-for-of: ^7.9.0 => 7.9.0
    @babel/plugin-transform-modules-commonjs: ^7.9.6 => 7.9.6
    @babel/plugin-transform-runtime: ^7.9.6 => 7.9.6
    @babel/preset-env: ^7.9.6 => 7.9.6
    @babel/preset-flow: ^7.9.0 => 7.9.0
    @babel/register: ^7.9.0 => 7.9.0
    @babel/runtime: ^7.9.6 => 7.9.6
    babel-eslint: ^11.0.0-beta.2 => 11.0.0-beta.2
    babel-jest: ^24.9.0 => 24.9.0
    babel-plugin-transform-charcodes: ^0.2.0 => 0.2.0
    eslint: ^6.8.0 => 6.8.0
    gulp-babel: ^8.0.0 => 8.0.0
    jest: ^24.9.0 => 24.9.0
    lerna: ^3.19.0 => 3.19.0
    rollup-plugin-babel: ^4.4.0 => 4.4.0

Possible Solution

Additional context
Add any other context about the problem here. Or a screenshot if applicable

@babel-bot
Copy link
Collaborator

Hey @yulanggong! 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."

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants