SumType alias can't be deduced?

Emmanuelle VuLXn6DBW at
Mon Feb 21 18:43:18 UTC 2022


import std.sumtype;

struct Unit {}
alias Option(T) = SumType!(T, Unit);

void foobar(T)(Option!T option) {}

void main() {

If you run this, the compiler should emit this error:

onlineapp.d(14): Error: template `onlineapp.foobar` cannot deduce 
function from argument types `!()(SumType!(int, Unit))`
onlineapp.d(8):        Candidate is: `foobar(T)(Option!T option)`

If you change `foobar`’s parameter’s type from `Option!T` to 
`SumType!(T, Unit)`, it  compiles without error.

Surely this is not intended? Is this a compiler bug or am I doing 
something wrong?


More information about the Digitalmars-d-learn mailing list