Skip to content

Conversation

@NotHyper-474
Copy link

@NotHyper-474 NotHyper-474 commented Jan 16, 2026

Fixes #277

This addresses a few things I've noticed:

  • Checking locals in resolve is practically useless, since locals will have already been checked before hscript's expr calls it. I've debugged, and the only instance where locals were checked here was when they persisted due to a bug.
  • Reverts the change of executeEx to exprReturn, seems like the bug that was fixed by it was subsequently resolved by a different change. This solves local variables persisting in static functions.
  • Copies the fix from [BUGFIX] Fix locals getting dropped after calling script's own scriptCall #257 to apply it to static functions; solves static properties dropping local variables.

And remove unnecessary checking for locals in `resolve`
@NotHyper-474
Copy link
Author

NotHyper-474 commented Jan 19, 2026

Also, the bug I'm talking about in the second point used to affect this repro script.

import funkin.modding.base.Object;

class StaticFunctionRepro extends Object
{
  public static function init():Void
  {
    var save = {version: "1.0"};
    var result = StaticFunctionRepro.checkSaveData(save);
    trace(result);
  }

  public static function checkSaveData(saveData:Dynamic):Dynamic
  {
    if (saveData.version != "2.0")
    {
      trace('Save data is outdated! Migrating...');
      saveData = migrateSaveData(saveData);
    }

    trace('Save data is good!');

    var updatedSaveData:Dynamic = getDefaultSaveData();
    return updatedSaveData;
  }

  public static function migrateSaveData(saveData:Dynamic):Dynamic
  {
    saveData.version = "2.0";
    return saveData;
  }

  public static function getDefaultSaveData():Dynamic
  {
    return {version: "2.0", other: true};
  }
}

After calling init, the local variables would act pretty weirdly, errors would be thrown as if they didn't exist. But now, even when replacing exprReturn with executeEx in the interp, which should've re-introduced the issue, it doesn't happen anymore.

@EliteMasterEric EliteMasterEric self-requested a review January 19, 2026 22:55
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