diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-03-15 00:46:33 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-03-15 00:46:33 +0100 |
commit | faad6ed67ffcb450c8ab5b2697c917990686f80a (patch) | |
tree | 5fc86ad9c0d504c52a2a1d93f974a9efffe83b4a | |
parent | b7cba7fa2945087df3ce674345c5f7408aa964a8 (diff) | |
parent | 669db4216e91dcd234f1ed56b7de44980f0bbcca (diff) | |
download | Nim-faad6ed67ffcb450c8ab5b2697c917990686f80a.tar.gz |
Merge pull request #2333 from def-/recursive-type
Fix infinite recursion in semtypes with recursive types
-rw-r--r-- | compiler/semtypes.nim | 2 | ||||
-rw-r--r-- | tests/types/tinfiniterecursion.nim | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index ac0636211..8a9f4a988 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -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 diff --git a/tests/types/tinfiniterecursion.nim b/tests/types/tinfiniterecursion.nim new file mode 100644 index 000000000..52eaaa93b --- /dev/null +++ b/tests/types/tinfiniterecursion.nim @@ -0,0 +1,8 @@ +discard """ + errormsg: "illegal recursion in type 'XIM'" + line: 8 +""" + +type + XIM* = ptr XIM + XIMProc* = proc (a2: XIM) |