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
- How to get compiler to warn/error on missing return statement i... wilsonywx2
- How to get compiler to warn/error on missing return statem... PMunch