wiremod/wire

Optimizer does not maintain scoping in case of if(1)

foul11 opened this issue · 2 comments

foul11 commented
local X = 1

if (1) {
    local X = X + 1
    print(X) -- printed '2'
}

print(X) -- printed '2'
local X = 1

if (X) {
    local X = X + 1
    print(X) -- printed '2'
}

print(X) -- printed '1'
Vurv78 commented

Probably thanks to the optimizer, which is being removed in #2555, considering the bottom one works but the top doesn't.

Vurv78 commented

Yeah this is already a test in the new compiler. So this is fixed by it.

local Number = 55
if (1) {
local Number = 60
assert(Number == 60)
}
assert(Number == 55)