Merge pull request #2333 from def-/recursive-type
Fix infinite recursion in semtypes with recursive types
This commit is contained in:
commit
faad6ed67f
2 changed files with 10 additions and 0 deletions
|
|
@ -787,6 +787,8 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||||
result = addImplicitGeneric(typ)
|
result = addImplicitGeneric(typ)
|
||||||
else:
|
else:
|
||||||
for i in 0 .. <paramType.sons.len:
|
for i in 0 .. <paramType.sons.len:
|
||||||
|
if paramType.sons[i] == paramType:
|
||||||
|
globalError(info, errIllegalRecursionInTypeX, typeToString(paramType))
|
||||||
var lifted = liftingWalk(paramType.sons[i])
|
var lifted = liftingWalk(paramType.sons[i])
|
||||||
if lifted != nil:
|
if lifted != nil:
|
||||||
paramType.sons[i] = lifted
|
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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue