From b39302b0d2e2771b34283ef9f43d9971f206a2a6 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 14 Oct 2018 13:19:33 +0200 Subject: DFA: implement exception handling properly --- tests/destructor/tprevent_assign2.nim | 46 +++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/destructor/tprevent_assign2.nim b/tests/destructor/tprevent_assign2.nim index 4ef62d2fd..feb635964 100644 --- a/tests/destructor/tprevent_assign2.nim +++ b/tests/destructor/tprevent_assign2.nim @@ -1,6 +1,12 @@ discard """ errormsg: "'=' is not available for type ; requires a copy because it's not the last read of 'otherTree'" - line: 44 + + cmd: "nim check --hint[Performance]:off $file" + nimout: ''' +tprevent_assign2.nim(53, 31) Error: '=' is not available for type ; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(52, 13) +tprevent_assign2.nim(55, 31) Error: '=' is not available for type ; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(52, 13) +tprevent_assign2.nim(66, 29) Error: '=' is not available for type ; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(68, 9) +''' """ type @@ -19,18 +25,21 @@ proc take2(a, b: sink Foo) = proc allowThis() = var otherTree: Foo - for i in 0..3: - while true: - #if i == 0: - otherTree = createTree(44) - case i - of 0: - echo otherTree - take2(createTree(34), otherTree) - of 1: - take2(createTree(34), otherTree) - else: - discard + try: + for i in 0..3: + while true: + #if i == 0: + otherTree = createTree(44) + case i + of 0: + echo otherTree + take2(createTree(34), otherTree) + of 1: + take2(createTree(34), otherTree) + else: + discard + finally: + discard proc preventThis() = var otherTree: Foo @@ -46,3 +55,14 @@ proc preventThis() = take2(createTree(34), otherTree) else: discard + +proc preventThis2() = + var otherTree: Foo + try: + try: + otherTree = createTree(44) + echo otherTree + finally: + take2(createTree(34), otherTree) + finally: + echo otherTree -- cgit 1.4.1-2-gfad0