title: How does numba infer the types of literally initialized locals?
body: <p>Numba does something cool and surprising:</p>
  
  <pre><code>@jit(nopython=True, nogil=True)
  def sum(arr):
      result = 0
      for i in range(len(arr)):
          result += arr[i]
      return result
  </code></pre>
  
  <p>When called with an int64 array, it returns an int. When called with a float64, it returns a float.</p>
  
  <p>This is suprising since, result is initialized with a literal integer 0 -- which I assumed it would determine the type of result. Why isn't the result always an int?</p>
  
  <p>Here's when <code>sum.inspecttypes()</code> says for the float64 array case:</p>
  
  <pre><code>================================================================================
  sum (readonly array(float64, 1d, C),)
  --------------------------------------------------------------------------------
  # File: /home/.../fast_ops.py
  # --- LINE 164 --- 
  # label 0
  #   del $const0.1
  
  @jit(nopython=True, nogil=True)
  
  # --- LINE 165 --- 
  
  def sum(arr):
  
      # --- LINE 166 --- 
      #   arr = arg(0, name=arr)  :: readonly array(float64, 1d, C)
      #   $const0.1 = const(int, 0)  :: int64
      #   result = $const0.1  :: float64
      #   jump 6
      # label 6
  
      result = 0
  </code></pre>