Skip to content

[BUG] Calling a static function after another static function can drops its argument values #277

@Starexify

Description

@Starexify

Description

When I try to use this example script:

import funkin.modding.events.ScriptEvent;
import funkin.modding.module.ScriptedModule;

class ShenaniganOne extends ScriptedModule {
    /**
     * Calling a setter and static function crashes the game
     *
     * If `value` is changed to a diff name for the variable or argument it will work again
     */
    static var _instance:ShenaniganOne;
    public static var instance(get, set):ShenaniganOne;
    static function set_instance(value:ShenaniganOne):ShenaniganOne { return _instance = value; }
    static function get_instance():ShenaniganOne { return _instance; }

    public static function testFunc() {
        var value;
    }

    override public function onCreate(event:ScriptEvent) {
        testFunc();
        ShenaniganOne.instance = this;
    }
}

polymod crashes with the following log:

Null Object Reference
 in polymod/hscript/_internal/PolymodScriptClass.hx#640
 in polymod/hscript/_internal/HScriptedClassMacro.hx#917
 in funkin/modding/events/ScriptEventDispatcher.hx#34
 in funkin/modding/module/ModuleHandler.hx#157
 in funkin/InitState.hx#294
 in funkin/InitState.hx#72
 in flixel/FlxGame.hx#588
 in flixel/FlxGame.hx#340

If I changed the name of var value; or the argument (value:Test) from the setter to something else, the crash doesn't happen.

The issue seems to be related to this: FunkinCrew/Funkin#5765

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions