Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Bug: Unreachable code #134

Closed loilo closed 7 years ago

loilo commented 7 years ago

From trying to squash canvasXpress—man, these minified sources are real treasure chests for finding bugs.

Butternut seems to have problems with unreachable code after premature return statements. It removes variables but—appears to me as a known pattern by now—not their values.

Input:

function any_fn () {
    return false
    var any_value_1 = function(d) {
        return any_value_2
    }
}

Output Butternut:

function any_fn(){return!1;function(a){return any_value_2}}

Output UglifyJS:

function any_fn(){return!1}