From 1bc5ff6dc912d3bfdd7dbbed88d06bce18804db3 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 8 Jan 2013 08:11:21 +0100 Subject: [PATCH] fixes #292 --- compiler/sempass2.nim | 9 ++++++--- tests/compile/teffects1.nim | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/compile/teffects1.nim diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index bd8a3ba02b..b2fd0fb042 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -1,7 +1,7 @@ # # # The Nimrod Compiler -# (c) Copyright 2012 Andreas Rumpf +# (c) Copyright 2013 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -146,8 +146,11 @@ proc catches(tracked: PEffects, e: PType) = dec L else: inc i - setLen(tracked.exc.sons, L) - + if not isNil(tracked.exc.sons): + setLen(tracked.exc.sons, L) + else: + assert L == 0 + proc catchesAll(tracked: PEffects) = if not isNil(tracked.exc.sons): setLen(tracked.exc.sons, tracked.bottom) diff --git a/tests/compile/teffects1.nim b/tests/compile/teffects1.nim new file mode 100644 index 0000000000..49af28469b --- /dev/null +++ b/tests/compile/teffects1.nim @@ -0,0 +1,17 @@ + +type + PMenu = ref object + PMenuItem = ref object + +proc createMenuItem*(menu: PMenu, label: string, + action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = nil + +var s: PMenu +createMenuItem(s, "Go to definition...", + proc (i: PMenuItem, p: pointer) {.cdecl.} = + try: + echo(i.repr) + except EInvalidValue: + echo("blah") +) +