The current type checker (analog or atomic) allows reassignment of a variable to a different type in the same scope. This behavior is described as flow-sensitive typing. Consider the following code:
r = true
if (r) {
r = 5
}
r = r + 2
This will raise a type error on the last line, as r is a bool in the global scope, and an int only in the local scope of the if statement block. The code below however:
r = true
r = 5
r = r + 2
will not raise a type error, as the variable r takes on the type of its latest declaration, which is int. Future development can involve SSA and other optimizations which will substitute the current behavior.
The current type checker (analog or atomic) allows reassignment of a variable to a different type in the same scope. This behavior is described as flow-sensitive typing. Consider the following code:
This will raise a type error on the last line, as
ris aboolin the global scope, and anintonly in the local scope of the if statement block. The code below however:will not raise a type error, as the variable
rtakes on the type of its latest declaration, which isint. Future development can involve SSA and other optimizations which will substitute the current behavior.