What we haven't noticed is another type instability problem concerning the accumulator. In the preceding example, the double_sum function has a total variable that keeps track of the doubled numbers. The problem is that the variable was defined as an integer, but then the array may contain floating-pointer numbers instead. This problem can be easily revealed by running @code_warntype against both scenarios.
Here is the output of @code_warntype for when an array of integers is passed into the function:
Compare it with the output when an array of Float64 is passed:
If we call the function with an ...