petkaantonov/bluebird

Dead code in a function

Sonnerz opened this issue · 2 comments

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you can:

  1. What version of bluebird is the issue happening on?
    @3.7.2

  2. What platform and version? (For example Node.js 0.12 or Google Chrome 32)
    node 10.15.3

  3. Did this issue happen with earlier version of bluebird?
    Do not know

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

/node_modules/bluebird/js/release/util.js
Last line of function cannot be reached: eval(obj);

function toFastProperties(obj) {
    /*jshint -W027,-W055,-W031*/
    function FakeConstructor() {}
    FakeConstructor.prototype = obj;
    var receiver = new FakeConstructor();
    function ic() {
        return typeof receiver.foo;
    }
    ic();
    ic();
    return obj;
    eval(obj);
}

bluebird/src/util.js

Lines 213 to 216 in 400b6af

// Prevent the function from being optimized through dead code elimination
// or further optimizations. This code is never reached but even using eval
// in unreachable code causes v8 to not optimize functions.
eval(obj);

Why is this an issue for you? Is that an error message from a linter that accidentally ran across your node_modules folder?

Yes, a scan that included node_modules.
I needed to show that I followed through on an issue found, besides just highlighting it.