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

else if gets ignored if there's an and/or. #82

Closed tabularelf closed 1 year ago

tabularelf commented 1 year ago

What version of Catspeak are you using?

3.0.0-beta3

What happened?

I pulled the recent commits to my project so I could use them early. And after playing with them for a bit, I realized it wasn't working properly. So I went to check on the unit testing, and after making a copy and making a few small tweaks, I realized this following snippet does nothing.

a = 1
if (a == 4) or (a == 3) {
    print("Nice");
} else if (a == 1) {
    print("Nice2");
}

The whole unit test I made a modification of isn't a genuine unit test, but it was just to verify that it was working.

 test_add_force(function () : Test("engine-else-if-multiple-statements") constructor {
    var engine = new CatspeakEnvironment();
    engine.addFunction("print", function(_str) {
        show_message(_str);   
    });
    try {
        var asg = engine.parseString(@'
            a = 1
            if (a == 4) or (a == 3) {
                print("Nice");
            } else if (a == 1) {
                print("Nice2");
            }
        ');
        var _func = engine.compileGML(asg);
        _func();
    } catch (e) {
        fail(e.message);
    }
});