Type inference for recursive functions can be challenging:
factorial(integer n) = if n then n * factorial(n-1) else 1
When factorial(n-1) is called, the type may only be no_type at that point. Then, the result of using a no_type operand must be promoted to the other operand's type. So, integer_type * no_type results in integer_type.
Type inference for recursive functions can be challenging:
factorial(integer n) = if n then n * factorial(n-1) else 1
When
factorial(n-1)
is called, the type may only beno_type
at that point. Then, the result of using ano_type
operand must be promoted to the other operand's type. So,integer_type * no_type
results ininteger_type
.