sandstone-mc / sandstone

Sandstone | Next Generation Framework for Minecraft
https://sandstone.dev/
MIT License
174 stars 15 forks source link

Incorrect output with empty `execute` `run` callback #145

Closed GrantGryczan closed 1 year ago

GrantGryczan commented 2 years ago
MCFunction('test', () => {
    execute.as('@s').run('something', () => {});
    say(1);
    say(2);
    say(3);
});

outputs

execute as @s run say 1
say 2
say 3

This applies whether you specify the function name argument in run or not. Either way, it should create an empty function and run a function command there instead.

Similarly,

MCFunction('test', () => {
    execute.as('@s').run('something', () => {
        comment('test');
    });
    say(1);
    say(2);
    say(3);
});

outputs

execute as @s run # test
say 1
say 2
say 3
TheMrZZ commented 2 years ago

While this is indeed invalid, I don't plan on fixing that. It's semantically invalid to do execute run anyway, so there is no reason it should work inside Sandstone.

Best thing would be to throw an error.

GrantGryczan commented 2 years ago

I don't know what you mean. Perhaps you misread the issue? This is an actual problem during development when I haven't put commands in every function I've created yet as I am focused on testing other parts of the project. This is something I do very often.

TheMrZZ commented 2 years ago

Anyway, this will be fixed once I rewrite Sandstone's command backend. Same for incorrect line breaks that pop up in some commands.