Open metagn opened 4 years ago
proc foo(n: int): auto = if n < 5: return foo(n + 1) else: return 9 echo foo(3)
Error: internal error: getTypeDescAux(tyUntyped)
Error: cannot infer type of recursive call
return
result =
proc foo(n: int): auto = if n < 5: foo(n + 1) # Error: type mismatch: got <untyped> but expected 'int literal(9)' else: 9 echo foo(3)
$ nim -v Nim Compiler Version 1.0.6
workaround exchange if else branch, make first branch has concrete type
Example
Current Output
Expected Output
Additional Information
return
toresult =
does the same thing