import options
template p[T] = none(T)
discard p[int]
templat.nim(5, 10) Error: expression 'none(int)' is of type 'Option[system.int]' and has to be discarded
I think writing discard
in front of the template instantiation is a reasonable enough way to do what the compiler asks, no ? Now it's just being grumpy.
EDIT: I've tried new things and it may be yet-another-case of very unhelpful compiler messages.
import options
template p[T](): untyped = T.none
discard p[int]()
This builds. The main change might be the untyped
return type (note that typed
didn't work either, with the same weird message).
And last flabbergast, T.none
was fine but not none(T)
. I thought from UFCS both should be equivalent.