Skip to content

Issue with shadowed bindings not being accurately renamed #2378

Closed

Description

@bradencanderson

The way that babel is renaming identifiers is a little flaky. This gets corrupted:

function foo(a) {
  var a = a;
  return {a: function() {return a;}};
}

It compiles to:

"use strict";

function foo(a) {
  var _a = _a;
  return { a: function a() {
      return _a;
    } };
}

Activity

  1. changed the title [-]Identifiers are renamed incorrectly[/-] [+]Issue with shadowed bindings not being accurately renamed[/+] on Sep 14, 2015
  2. eventualbuddha commented on Sep 14, 2015

    @eventualbuddha
    Member

    Isn't this expected behavior? What would you expect to happen?

  3. bradencanderson commented on Sep 14, 2015

    @bradencanderson
    ContributorAuthor

    The parameter name should be renamed to _a also.

  4. eventualbuddha commented on Sep 14, 2015

    @eventualbuddha
    Member

    @bradencanderson I believe you're right. Sorry for the confusion!

  5. hzoo commented on Sep 21, 2016

    @hzoo
    Member

    outputs

    function foo(a) {
      var a = a;
      return { a: function () {
          return a;
        } };
    }
    

    in the repl now

  6. danharper commented on Sep 21, 2016

    @danharper
    Member

    @hzoo It doesn't look like function-naming ran on that example. On the current live repl I still get:

    "use strict";
    
    function foo(a) {
      var _a = _a;
      return { a: function a() {
          return _a;
        } };
    }
  7. reopened this on Sep 21, 2016
  8. kangax commented on Dec 21, 2016

    @kangax
    Member

    Pretty bizarre how with Babili I get correctly renamed version:

    "use strict";function foo(b){var b=b;return{a:function a(){return b}}}

    yet, it's still messed up w/o it:

    "use strict";

    function foo(a) {
      var _a = _a;
      return { a: function a() {
          return _a;
        } };
    }
  9. added a commit that references this issue on May 18, 2017
    98bef29
  10. added a commit that references this issue on Jul 24, 2017
    2225892
  11. added
    outdated
    on May 4, 2018
  12. locked as resolved and limited conversation to collaborators on May 4, 2018
  13. added a commit that references this issue on Sep 9, 2026
    8290ff9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions