fixes #13736; Compiler crash with auto return type and recursion

This commit is contained in:
ringabout
2026-07-29 22:38:57 +08:00
parent b3e21240a6
commit 02da2cf4ae
2 changed files with 16 additions and 0 deletions

View File

@@ -918,6 +918,10 @@ proc semResolvedCall(c: PContext, x: var TCandidate,
markUsed(c, info, finalCallee, isGenericInstance = true)
onUse(info, finalCallee, isGenericInstance = true)
if finalCallee == c.p.owner and finalCallee.typ.returnType != nil and
finalCallee.typ.returnType.kind == tyAnything:
localError(c.config, info, "cannot infer type of recursive call")
result = compactVoidArgs(x.call)
instGenericConvertersSons(c, result, x)
markConvertersUsed(c, result)

12
tests/errmsgs/t13736.nim Normal file
View File

@@ -0,0 +1,12 @@
discard """
errormsg: "cannot infer type of recursive call"
line: 8
"""
proc foo(n: int): auto =
if n < 5:
return foo(n + 1)
else:
return 9
echo foo(3)