summary refs log blame commit diff stats
path: root/tests/effects/teffects6.nim
blob: 6a4eea15539da05ea0c5589f7d8b48eb07b7ebf2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                            




                        
                                                
                                                                                





                                                 
                          


                      



                                                      
 

                                      






                                                     
discard """
action: compile
"""

# XXX: it is not actually tested if the effects are inferred

type
  PMenu = ref object
  PMenuItem = ref object

proc createMenuItem*(menu: PMenu, label: string,
                    action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = discard

var s: PMenu
createMenuItem(s, "Go to definition...",
      proc (i: PMenuItem, p: pointer) {.cdecl.} =
        try:
          echo(i.repr)
        except ValueError:
          echo("blah")
)


proc noRaise(x: proc()) {.raises: [].} =
  # unknown call that might raise anything, but valid:
  x()

proc doRaise() {.raises: [IoError].} =
  raise newException(IoError, "IO")

proc use*() =
  noRaise(doRaise)
  # Here the compiler inferes that EIO can be raised.


use()