cardillan / mindcode

A high level language for Mindustry Logic and Mindustry Schematics.

Home Page:http://mindcode.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong expression handling in loops

cardillan opened this issue · comments

The Data Flow Optimizer mishandles loop expression. This code

x = 0
while true
    print(x + 1)
    x = rand(10)
    print(x + 1)
end

compiles into

print __tmp2
op rand x 10 0
op add __tmp2 x 1
print __tmp2
jump 0 always 0 0

and produces (correctly) a warning about the __tmp2 variable being uninitialized.