orosmatthew / hydrogen-cpp

A hobby programming language 🔥
MIT License
391 stars 38 forks source link

Fixed If Statement Logic Error #15

Closed edy131109 closed 10 months ago

edy131109 commented 10 months ago

If statements would not skip to the end of the if-elif-else structure if they were true and didn't have an exit() inside of them.

For example with the following code

let x = 1;
if (x) {
    //exit(1);
}
elif (x + 1) {
    exit(2);
}
elif (x + 2) {
    exit(3);
}
else {
    exit(13);
}
exit(14);

You would expect the result to be 14 but instead we get 2 because after the if statement executes it jumps to the next elif statement instead of to the end of the structure.

This pull request just modifies two lines of code to fix that issue.

edy131109 commented 10 months ago

Fixed in newest video.