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

Overlapping names between nested closures #877

Closed
katyo opened this issue Nov 25, 2015 · 5 comments
Closed

Overlapping names between nested closures #877

katyo opened this issue Nov 25, 2015 · 5 comments

Comments

@katyo
Copy link

katyo commented Nov 25, 2015

I use UglifyJS a long time and I never had a similar problems.

Because the reproducing of this bug isn't trivial I created a gist located here https://gist.github.com/katyo/bd5a8811d63d77efeead

Gist

The source of function:

function replace(regex, options) {
  regex = regex.source;
  options = options || '';

  return function self(name, val) {
    if (!name) {
      return new RegExp(regex, options);
    }
    val = val.source || val;
    regex = regex.replace(name, val);
    return self;
  };
}

The result of uglification:

function e(e,t){e=e.source;t=t||"";return function n(r,n){if(!r){return new RegExp(e,t)}n=n.source||n;e=e.replace(r,n);return n}}

Human-readable version:

function e(e,t){
  e=e.source;
  t=t||"";
  return function n(r,n){
    if(!r){
      return new RegExp(e,t)
    }
    n=n.source||n;
    e=e.replace(r,n);
    return n
  }
}

Overlapping between function name self and variable name val (both named with n in result).

@mishoo
Copy link
Owner

mishoo commented Nov 25, 2015

Confirmed. Seems to happen only when sort is passed to the mangler. Just remove that flag for now, until we manage to fix. (if we even fix; I'm in favor of dropping that option completely).

@katyo
Copy link
Author

katyo commented Nov 25, 2015

Ok. Thanks.

@IngwiePhoenix
Copy link

Same for #990 - in fact, same function... x)

@kzc
Copy link
Contributor

kzc commented Feb 28, 2016

@rvanvelzen I think this original Issue can be closed by #991 as well.

@rvanvelzen
Copy link
Collaborator

@kzc absolutely right, thanks

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

5 participants