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

Unexpected UnaryExpression. Expected an Identifier #122

Closed
jbt opened this issue Aug 29, 2016 · 2 comments
Closed

Unexpected UnaryExpression. Expected an Identifier #122

jbt opened this issue Aug 29, 2016 · 2 comments
Labels
bug Confirmed bug

Comments

@jbt
Copy link

jbt commented Aug 29, 2016

I'm seeing the above error when I have lots of nested if/else's with the occasional empty block.

Stack trace if it's useful

Error: test.js: Unexpected UnaryExpression. Expected an Identifier
    at Mangler.renameNew (foo/node_modules/babel-plugin-minify-mangle-names/lib/index.js:193:19)
    at foo/node_modules/babel-plugin-minify-mangle-names/lib/index.js:143:23
    at Array.map (native)
    at Scopable (foo/node_modules/babel-plugin-minify-mangle-names/lib/index.js:135:16)
    at NodePath._call (foo/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (foo/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (foo/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (foo/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (foo/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (foo/node_modules/babel-traverse/lib/context.js:190:19)

Minimum example I could come up with (repl)

function foo() {
  var a, b, c;

  if (a) {
    if (b) {
      if (c) {}
    }
  } else {
    if (b) {
    } else {
      if (c) {}
    }
  }
}

Seems to be coming from the interaction of minify-dead-code-elimination and minify-mangle-names (both seem fine individually but fail when used together)

Error's being thrown here which suggests it might be an upstream Babel bug?

@boopathi boopathi added the bug Confirmed bug label Aug 29, 2016
@boopathi
Copy link
Member

Thanks for reporting.

It's an issue with mangler. Will take a look.

boopathi added a commit that referenced this issue Aug 29, 2016
boopathi added a commit that referenced this issue Aug 29, 2016
kangax pushed a commit that referenced this issue Aug 29, 2016
* Add fix for other types of nodes in referencePaths

+ (Close #122)
+ (Close #105)

* return after renaming

* It's not a return

* Add tests for export statements

* Add tests for #122
@jbt
Copy link
Author

jbt commented Aug 29, 2016

Nice one! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants