The easiest way to achieve this is to use implicit return, that way Nim will 
complain about branches missing a value:
    
    
    type
      X = ref Xobj
      Xobj = object
        x: int
      Ret = ref RetObj
      RetObj = object
        y: int
    
    proc fn(x: X): Ret =
      result = if isNil(x): # just an example, any condition is fine
          echo "ok"
        else:
          echo "ok too"
          Ret(y:42)
    
    var x: X
    doAssert isNil(fn(x))
    
    
    Run

Reply via email to