[Issue 14772] issuing errors for array ops -> tell users which function are missing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 5 15:35:18 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=14772

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #1 from Nick Treleaven <nick at geany.org> ---
The problem seems to be that `f` does not have length 1:

> Vector3[] f;

When that is fixed, it works:

struct Vector3 {
    public double[3] arr;
    Vector3 opBinary(string op)(in Vector3 rhs) const
    if (op == "+") {
        Vector3 result;
        result.arr[] = this.arr[] + rhs.arr[];
        return result;
    }
}

unittest {
    auto a = Vector3([2.0, 2.0, 0.0]);
    auto b = Vector3([1.0, 2.0, 1.0]);
    Vector3 e = a + b; // works
    Vector3[] c = [a];
    Vector3[] d = [b];
    Vector3[1] f;
    f[] = c[] + d[]; // works
}

Also I can't reproduce the original error with all the compilers on
run.dlang.io , maybe they don't go back that far.

--


More information about the Digitalmars-d-bugs mailing list