WingedSeal / jmc

A compiler for JMC (JavaScript-like Minecraft Function), a mcfunction extension language for making Minecraft Datapack
https://jmc.wingedseal.com
MIT License
62 stars 6 forks source link

[BUG] If statements break return statements and function macros #104

Open OguzhanUmutlu opened 2 weeks ago

OguzhanUmutlu commented 2 weeks ago

Describe the bug

If statements break into new functions inside private folder which breaks both /return and function macros

To Reproduce

Example code that breaks /return:

$a = 1;
function test() {
 if ($a == 1) {
    say "hi";
    return 1;
 }
 return 0;
}

$b = test();

tellraw @a $b.toString();

Example code that breaks function macros:

$x = 1;

function test() {
 if ($x == 1) {
  say "hi";
  $tellraw @a $(a);
 }
}

test({a: 10});

Expected behavior

First one should print out "hi" and "1", but instead it prints out "hi" and "0"

Second one should print out "hi" and "10", but instead it prints out nothing

Desktop

Nico314159 commented 2 weeks ago

Intended behavior.