closure-compiler
closure-compiler copied to clipboard
`@pureOrBreakMyCode` can't handle when left-hand side is array pattern
command java -jar closure-compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --formatting PRETTY_PRINT --js input.js --js_output_file compiled.js
the example code is trimmed from tc39 stage 3 decorator compiled by swc.
in the example,@pureOrBreakMyCode is added manually to ({ e: [_init_p3] } = /** @pureOrBreakMyCode */_apply_decs_2203_r(...)
however, because left-hand side is destructuring assignment, so closure-compiler need to traverse the lhs and valueNode respectively, it can't eliminate the pure valueNode.
reproducible code
/** @noinline */
const applyDecs2203RFactory = () => { return () => {} }
/** @noinline */
const _apply_decs_2203_r = applyDecs2203RFactory()
var _init_p3;
class A {
constructor(){
this.p3 = /** @pureOrBreakMyCode */_init_p3(this, "3");
}
}
({ e: [_init_p3] } = /** @pureOrBreakMyCode */_apply_decs_2203_r(1, 2, 3));