From c19d6cb6201d86b7fb3cabe33134b1d555881de4 Mon Sep 17 00:00:00 2001 From: def Date: Fri, 13 Mar 2015 02:17:46 +0100 Subject: [PATCH 1/3] Fix infinite recursion in semtypes with recursive types Fixes #2213 --- compiler/semtypes.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index ac06362114..5e9e584ebb 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 .. Date: Fri, 13 Mar 2015 17:17:42 +0100 Subject: [PATCH 2/3] globalError instead of localError when failing infinite recursion globalError throws an exception, so this works for `nim check` as well. --- compiler/semtypes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 5e9e584ebb..8a9f4a988e 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -788,7 +788,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode, else: for i in 0 .. Date: Sat, 14 Mar 2015 22:46:17 +0100 Subject: [PATCH 3/3] Add test case for infinite recursion in semtypes --- tests/types/tinfiniterecursion.nim | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/types/tinfiniterecursion.nim diff --git a/tests/types/tinfiniterecursion.nim b/tests/types/tinfiniterecursion.nim new file mode 100644 index 0000000000..52eaaa93b0 --- /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)