summary refs log blame commit diff stats
path: root/tests/ccgbugs/t9286.nim
blob: 8a45a7bf6003f2ccac2ac1ad472ab53f083835ae (plain) (tree)





















                                   
discard """
  action: run
"""

import options
type Foo  = ref object
  i:      int

proc next(foo: Foo): Option[Foo] =
  try:    assert(foo.i == 0)
  except: return      # 2º: none
  return some(foo)    # 1º: some

proc test =
  let foo = Foo()
  var opt = next(foo) # 1º Some
  while isSome(opt) and foo.i < 10:
    inc(foo.i)
    opt = next(foo)   # 2º None
  assert foo.i == 1, $foo.i

test()