mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-31 20:49:06 +00:00
fixes #13736; Compiler crash with auto return type and recursion
This commit is contained in:
@@ -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
12
tests/errmsgs/t13736.nim
Normal 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)
|
||||
Reference in New Issue
Block a user