mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-26 04:45:08 +00:00
Merge pull request #2333 from def-/recursive-type
Fix infinite recursion in semtypes with recursive types
This commit is contained in:
@@ -787,6 +787,8 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||
result = addImplicitGeneric(typ)
|
||||
else:
|
||||
for i in 0 .. <paramType.sons.len:
|
||||
if paramType.sons[i] == paramType:
|
||||
globalError(info, errIllegalRecursionInTypeX, typeToString(paramType))
|
||||
var lifted = liftingWalk(paramType.sons[i])
|
||||
if lifted != nil:
|
||||
paramType.sons[i] = lifted
|
||||
|
||||
8
tests/types/tinfiniterecursion.nim
Normal file
8
tests/types/tinfiniterecursion.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
discard """
|
||||
errormsg: "illegal recursion in type 'XIM'"
|
||||
line: 8
|
||||
"""
|
||||
|
||||
type
|
||||
XIM* = ptr XIM
|
||||
XIMProc* = proc (a2: XIM)
|
||||
Reference in New Issue
Block a user