www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14916] New: opDispatch: no property error for parameter type

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

          Issue ID: 14916
           Summary: opDispatch: no property error for parameter type
                    mismatch
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: luis luismarques.eu

unittest // getter is fine
{
    struct S
    {
        auto opDispatch(string name)()
        {
            return 42;
        }
    }

    S s;
    s.foo;
}

unittest // setter is fine
{
    struct S
    {
        void opDispatch(string name)(ushort value)
        {
        }
    }

    S s;

    s.foo = 42; // fine

    long x = 42;
    s.foo = x; // correct error: "not callable using argument types (long)"
}

unittest // getter and setter... bug: misleading error
{
    struct S
    {
        auto opDispatch(string name)()
        {
            return 42;
        }

        void opDispatch(string name)(ushort value)
        {
        }
    }

    S s;

    s.foo = 42; // fine

    long x = 42;
    s.foo = x; // *wrong* error: "no property 'foo' for type 'S'"
}

--
Aug 13 2015