katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
92 stars 6 forks source link

Static constructor methods not respected in scope #65

Closed tabularelf closed 1 year ago

tabularelf commented 1 year ago

I’ve mostly moved over to catspeak v3 in my current project… Came across a few oddities that I wasn’t getting previously. But from my testing, it seems that catspeak isn’t fond of static methods from a constructor.

If I have a constructor that I pass to Catspeak as a function like

Catspeak.addFunction("Construct", function() {
    return new Construct();
});

And Construct has

function Construct() constructor {
    str = "";

    static add = function(_str) {
        str += string(_str);
    }
}

Trying to do this in Catspeak results in it trying to access the compiled Catspeak program as the scope, and not the constructor instance. Hence causing an error/modifying the wrong instance.

var _inst = Construct();
_inst.add("Woo!");