I'm going to provide a reduced case for the issue you are having.

struct Foo {
    double x;
    alias x this;
}

void main() {
    Foo a;
    a = 8; // Alias this assignment
    assert(a.x == 8);
    fun(7); // What you want
}

void fun(Foo a) {
}

You're claiming that since Foo is requested to "be" a double calling fun(7) should just assign 7 to x.

What you're missing is that it is Foo which behaves like double, however fun(7) there is no Foo involved, it doesn't exist. You're actually requesting that a Foo is created, then to have an assignment of 7 to x of the new temporary Foo.

This is not a bug, it is by design. Alias this is sugar of type it is declared in not the type it is declared to.

Reply via email to