Ratstail91 / Toy

The Toy Programming Language.
https://toylang.com/
zlib License
231 stars 11 forks source link

Extra Scopes used around FOR then-path #107

Closed Ratstail91 closed 1 year ago

Ratstail91 commented 1 year ago

remove these and test it

Ratstail91 commented 1 year ago

for loops normally look like this

{
    pre clause
    conditional
    if false jump to end
    {
        body
    }
    post clause
    jump to conditional
    end
}
pop stack

If you unilaterally removed the scope around the body, then this would break:

for (var i = 0; i < 10; i++) var j = null; //j gets declared over and over again.

Might need to insert scope implicitly when not detected...