Here is a reduced code:

import std.stdio;

enum Type { Int, Float }

auto foo(Type t)
{
    final switch (t) {
    case Type.Int:
        return 42;
    case Type.Float:
        return 1.5;
    }
}

void main()
{
    writeln(foo(Type.Int));
    writeln(foo(Type.Float));
}

The return type of foo() is double. (It's float in your code but it doesn't matter.)

I think this is a bug. I guess that 'return 42' is still placing an int onto the program stack instead of a float. A workarounds are returning to!float(this._num.ivalue).

But I think this is a compiler bug.

Ali

I should begin to count the bugs I find with stuff like this. :)
So no correct workaround, hm?

I tried to use a Variant and in the getter method "get" and even "coerce" but then i get the error, that the type of "get" cannot be detected.

Reply via email to