Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Calling node.parent() on ternary operator fails #7

Open
nhusher opened this Issue · 4 comments

4 participants

@nhusher

Using burrito@0.2.11:

burrito('var foo = bar ? baz : null', function(node) {
    console.log(node.source());
    node.parent();        
});

When it hits the "bar" node, calling parent fails with the following stack trace:

TypeError: Object name has no method 'slice'
    at walk (/uglify-js/lib/process.js:220:51)
    at make_block_statements (/uglify-js/lib/process.js:1778:36)
    at Array.<anonymous> (/uglify-js/lib/process.js:1497:32)
    at walk (/uglify-js/lib/process.js:215:47)
    at /uglify-js/lib/process.js:1715:31
    at Object.with_walkers (/uglify-js/lib/process.js:232:27)
    at Object.gen_code (/uglify-js/lib/process.js:1492:18)
    at /burrito/index.js:32:26
    at Object.wrap (/burrito/index.js:72:22)
    at /burrito/index.js:145:14
@Tattoo

Still exists in burrito@0.2.12

@Tattoo

Main issue with this is, calling the .parent() is un-catchable, so a developer cannot mitigate the situation:

burrito( "true ? true : false;", function( node ){
  console.log( node.source() );
  try {
    console.log( node.parent() );
  } catch ( ex ){
    console.log( "failed" );
  }
});

Still produces error stack when it hits the .parent() call:

TypeError: Object name has no method 'slice'
    at walk (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:220:51)
    at make_block_statements (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:1830:36)
    at Array.<anonymous> (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:1542:32)
    at walk (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:215:47)
    at ~/node_modules/burrito/node_modules/uglify-js/lib/process.js:1765:31
    at Object.with_walkers (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:243:27)
    at Object.gen_code (~/node_modules/burrito/node_modules/uglify-js/lib/process.js:1537:18)
    at ~/node_modules/burrito/index.js:32:26
    at Object.wrap (~/node_modules/burrito/index.js:72:22)
    at ~/node_modules/burrito/index.js:145:14

Because of this, I hope this issue could be fixed ASAP

@framlin

seems to be same problem as I discribes at #9

so because parent is not catchable, burrito is un-usable at the moment :-(

@chenjinya

I meet the same problem.How to deal with that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.