21 lines
573 B
Mojo
21 lines
573 B
Mojo
# probe: var shadowing inside if and loop blocks
|
|
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
|
# expect-stdout: inner 11
|
|
# expect-stdout: outer 1
|
|
# expect-stdout: loop 0
|
|
# expect-stdout: loop 100
|
|
# expect-stdout: loop 200
|
|
# expect-stdout: total 0
|
|
def main():
|
|
var x = 1
|
|
if x == 1:
|
|
var x = 10
|
|
x += 1
|
|
print("inner", x)
|
|
print("outer", x)
|
|
var total = 0
|
|
for i in range(3):
|
|
var total = i * 100
|
|
print("loop", total)
|
|
print("total", total)
|