duncantl / RTypeInference

Tools for inferring the types of inputs and outputs for functions and expressions
14 stars 0 forks source link

Inferring types of locals #2

Closed duncantl closed 9 years ago

duncantl commented 9 years ago

In the isum example again

isum =
function(x, n)
{
  total = 0
  for(i in 1:n)
      total = total + x[i]
  total
}

Can we get the type inference to recognize that, if x is VectorType(NumericType()), then total should be numeric and not integer. The RLLVMCompile currently uses the heuristic that total would be an integer, but it doesn't look ahead.

nick-ulle commented 9 years ago

The fork already does this, because it recognizes that x is numeric, so total + x[i] will upcast to numeric.

duncantl commented 9 years ago

Great.