katsaii / catspeak-lang

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

func.setSelf(<instance>) leads to error due to GM's native is_struct() failing #50

Closed JujuAdams closed 1 year ago

JujuAdams commented 1 year ago

The .setSelf() method on functions returned by Catspeak.compileGML() uses is_struct() to verify whether the provided target is valid (when CATSPEAK_DEBUG_MODE is set to true). Unfortunately, is_struct() returns false if passed an instance struct which then causes .setSelf() to error out despite an instance struct being a valid target.

Issue is easy enough to repro. Ensure CATSPEAK_DEBUG_MODE is set to true and then execute the following in the scope of an object instance:

func = Catspeak.compileGML(_asg);
func.setSelf(self);

I'm testing on IDE v2022.0.0.19 Runtime v2022.0.0.12 so this is_struct() behaviour might have changed in newer versions.