This type of “type instability” has no impact on performance and the compiler is smart enough to not have a problem with it.
The printer for code_warntype
could be a bit smarter perhaps.
Feel free to reassign variables in functions as you wish. It is only a problem if the variable doesn’t get properly inferred at some place where it is used in the function.