You are not supposed to use `not nil` types as Option generic parameters, 
Options check if a type is ref or ptr or proc then assume their nil values to 
be `None` instead of using an extra bool discriminator, so `some(nil)` is also 
disallowed. You used `Option[Foo]` where `Foo` is not nil. There is also a 
convenience proc for `if f != nil: some(f) else: none(Foo)`, `option(f)`.

`not nil` is pretty weak and probably won't grow into a full stable feature. 
There are [a couple open 
issues](https://github.com/nim-lang/Nim/issues?q=is%3Aopen+is%3Aissue+label%3A%22Not+nil+checking%22)
 (this label is misleading, there's other nil errors in the closed issues) but 
they're very old.

There is an alternate proposal for [nilability and nil 
types](https://github.com/alehander92/RFCs/blob/master/RFCs/nilcheck.rst) that 
might go into effect some time soon, and the Nim compiler is getting bindings 
to Microsoft's Z3 theorem prover engine under a new tool called "drnim". All I 
can say is you need to wait.

Reply via email to