Acknowledged

private static constants are incorrectly optimized in sdk-6.2.0

Example:

class Broken {
    private static const FOO = 42;
    public static function getFoo() as Number {
        return Broken.FOO; // <-- crashes here
    }
}
(:test)
function testBroken(logger as Logger) as Boolean {
    logger.debug(Broken.getFoo());
    return true;
}

Prior to sdk-6.2.0, this works as expected (except in 4.1.6, which had a similar, but not identical bug). In sdk-6.2.0 at -O0, it also works.

But at -O1 and above, it crashes on line 4. As far as I can tell, the optimizer has removed the definition of FOO from class Broken, but is still referencing it from getFoo().

Looking at the -g output, in 4.1.7 through 4.2.4, the body of getFoo is optimized to:

    argc 1
    ipush 42
    return

in other words "return 42;". In 6.2.0 its not optimized at all:

    argc 1
    lgetv 0
    spush Broken
    getv
    spush <globals/Broken/<statics>/<>FOO>
    getv
    return

In both cases, FOO has been removed from the globals/Broken/<statics> CLASSDEF.

So it seems that 6.2.0 introduced a disconnect between the code that removes unused constant definitions, and the code that is supposed to optimize away their uses.