Skip to content

Comments

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

Merged
AbnormalPoof merged 1 commit intoFunkinCrew:experimentalfrom
KoloInDaCrib:patch-1
Feb 20, 2026
Merged

[BUGFIX] Fix globals getting removed after calling a function with the same argument name#348
AbnormalPoof merged 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.

Copy link
Member

@AbnormalPoof AbnormalPoof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works great!

hscriptClass(assets/TestScript.hxc):40: goomba

also recreated the repro in try haxe and the output is the same there
Image

@AbnormalPoof AbnormalPoof merged commit c07b395 into FunkinCrew:experimental Feb 20, 2026
@KoloInDaCrib KoloInDaCrib deleted the patch-1 branch February 20, 2026 18:44
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.

2 participants