Hi!
I found syntax to make me a generic Object variant:
type myType = enum ok, error
type myVariant[T] = object
case kind: myType
of ok: value: T
of error: msg: string
Now when constructing such an object, I need to pass the type T, even when it could be inferred (or at least, it seems to me that it could). Why is that?
myVariant(kind: ok, value: 42) is not accepted by the compiler, though T has to be an int myVariant[int](kind: ok, value: 42) is fine. I understand that myVariant(kind: error, msg: "oops") is ambiguous, as is myVariant(kind: ok).
A related question might be why the latter is valid - I'd be happy if the compiler enforced a value for the value field, because I can always make it optional in other ways.