node-jscoverage icon indicating copy to clipboard operation
node-jscoverage copied to clipboard

Fix: instrumentation breaks `new(require('foo'))(args)`

Open andreyvit opened this issue 13 years ago • 0 comments

Fix a missing parenthesis when generating code for a new() statement applied to an expression, like the example:

new(require('foo'))(args)

which used to generate

new require('foo')(args)

resulting in the returned function being called without 'new'.

I have no idea why on earth TOK_LP calls instrument_function_call; it seems to treat all parethesized expressions as function calls, but I didn't feel like investigating that.

andreyvit avatar Nov 22 '12 09:11 andreyvit