From fb641483f0e2ed974b89d629ea5ec28e5e6145ce Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 18 Mar 2020 16:57:34 +0100 Subject: arc optimizations (#13325) * scope based destructors * handle 'or' and 'and' expressions properly, see the new test arc/tcontrolflow.nim * make this branch mergable, logic is disabled for now --- tests/destructor/tasync_prototype.nim | 5 +++++ tests/destructor/tdestructor.nim | 2 +- tests/destructor/tmisc_destructors.nim | 2 +- tests/destructor/tv2_raise.nim | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/destructor') diff --git a/tests/destructor/tasync_prototype.nim b/tests/destructor/tasync_prototype.nim index bd80adf0c..81fd824e9 100644 --- a/tests/destructor/tasync_prototype.nim +++ b/tests/destructor/tasync_prototype.nim @@ -32,7 +32,12 @@ proc serve(server: PAsyncHttpServer): PFutureBase = yield acceptAddrFut var fut = acceptAddrFut.value + # with the new scope based destruction, this cannot + # possibly work: var f {.cursor.} = processClient() + # It also seems to be the wrong way how to avoid the + # cycle. The cycle is caused by capturing the 'env' + # part from 'env.f'. when true: f.callback = proc () = diff --git a/tests/destructor/tdestructor.nim b/tests/destructor/tdestructor.nim index 5cfecea4e..b6d60323c 100644 --- a/tests/destructor/tdestructor.nim +++ b/tests/destructor/tdestructor.nim @@ -33,7 +33,7 @@ type p: pointer proc `=destroy`(o: var TMyObj) = - if o.p != nil: + if o.p != nil: dealloc o.p o.p = nil echo "myobj destroyed" diff --git a/tests/destructor/tmisc_destructors.nim b/tests/destructor/tmisc_destructors.nim index 53c67e34b..73c54eab3 100644 --- a/tests/destructor/tmisc_destructors.nim +++ b/tests/destructor/tmisc_destructors.nim @@ -22,7 +22,7 @@ proc `=`(dest: var Foo, src: Foo) = assign_counter.inc proc test(): auto = - var a,b : Foo + var a, b: Foo return (a, b, Foo(boo: 5)) var (a, b, _) = test() diff --git a/tests/destructor/tv2_raise.nim b/tests/destructor/tv2_raise.nim index 828d0a396..4ea94a864 100644 --- a/tests/destructor/tv2_raise.nim +++ b/tests/destructor/tv2_raise.nim @@ -2,7 +2,7 @@ discard """ valgrind: true cmd: '''nim c -d:nimAllocStats --newruntime $file''' output: '''OK 3 -(allocCount: 8, deallocCount: 3)''' +(allocCount: 8, deallocCount: 5)''' """ import strutils, math -- cgit 1.4.1-2-gfad0 ang/Nim/blame/?h=devel&id=371b416ac818412909243d10a66c20db3eaa23f3'>root/tests/exception/tfinally2.nim
blob: dae1a468a5a657995d0f64bfa33d6890895b37c3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
           

           

 

   
   

                              
                





                  

                       
              
                


                     
          
             
 
              
discard """
output: '''
A
B
C
D
'''
"""
# Test break in try statement:

proc main: int =
  try:
    block AB:
      try:
        try:
          break AB
        finally:
          echo("A")
        echo("skipped")
      finally:
        block B:
          echo("B")
      echo("skipped")
    echo("C")
  finally:
    echo("D")

discard main()