Skip to content

[BUGFIX] Fix globals getting removed after calling a function with the same argument name#348

Open
KoloInDaCrib wants to merge 1 commit intoFunkinCrew:experimentalfrom
KoloInDaCrib:patch-1
Open

[BUGFIX] Fix globals getting removed after calling a function with the same argument name#348
KoloInDaCrib wants to merge 1 commit intoFunkinCrew:experimentalfrom
KoloInDaCrib:patch-1

Conversation

@KoloInDaCrib
Copy link

@KoloInDaCrib KoloInDaCrib commented Feb 17, 2026

Minimal reproduction method:

import funkin.modding.module.Module;

class TestModule extends Module
{
  var thing:String;

  public function onCreate(event:ScriptEvent)
  {
    super.onCreate(event);

    this.test("goomba");
    trace(thing); // Should trace "goomba" but traces null
  }

  function test(thing:String)
  {
    this.thing = thing;
  }
}

This is because in PolymodScriptClass' callFunction function, every variable from interp that wasn't a previously defined variable gets removed, which includes function arguments. Pair that with naming a global variable the same as the function argument, and the result is that the global variable gets its value reset after exiting the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments