Skip to content

Variable redeclarations are not recognized as modifications #6217

Closed

Description

@RubenVerborgh

Bug report

Input Code

var a = 1;
var a = 2;
var b = 1, b = 2;

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

Default.

Expected Behavior

Babel recognizes that a and b are not constants.

Current Behavior

Babel reports that a and b are constants.

Possible Solution

In babel-traverse, registerBinding incorrectly assumes that each variable name of a declaration is a new name and does not exist yet in the bindings.

Context

The incorrect constantness assumption breaks babel-minify (babel/minify#685).

Your Environment

All.

Activity

  1. babel-bot commented on Sep 8, 2017

    @babel-bot
    Collaborator

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

  2. jridgewell commented on Sep 8, 2017

    @jridgewell
    Member

    This was fixed in #5745.

  3. RubenVerborgh commented on Sep 8, 2017

    @RubenVerborgh
    ContributorAuthor

    This does not seem to be fixed; still fails in latest master, which includes #5745.

  4. added a commit that references this issue on Sep 9, 2017
    6560a29
  5. added
    outdated
    on May 4, 2018
  6. locked as resolved and limited conversation to collaborators on May 4, 2018
  7. added a commit that references this issue on Sep 9, 2026
    b036a6d
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

    outdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions