Skip to content

Minified JS causes use of variable before initialization #146

@masonfrykman

Description

@masonfrykman

Hey! I tried to minify some JS code and Chrome gave me a fun Uncaught ReferenceError: Cannot access '_B' before initialization when I ran it.

This is the source code before it was minified

let degI = degFloor + degGrowthFactor * i
while(degI > 360) {
    degI -= 360
}

// find the x & y extensions
let theta = (degI * Math.PI) / 180 // convert degrees to radians
let a = lineLength * Math.sin(theta) // this will be the y extension
let b = lineLength * Math.cos(theta) // this will be the x extension

This is the problematic code after minification

let _a = _i + J * i
, a = E * Math.sin(_B)
, b = E * Math.cos(_B);
while (_a > 360)
    _a -= 360;
let _B = (_a * Math.PI) / 180;

F.Y.I, this was generated w/ v15.2.0
Also for more context, the code is inside a for loop, if y'all need the entire file I can provide it,,,

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions