[Issue 22769] New: `fun()` where fun is a property which returns an object with opCall should call opCall

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 13 18:28:37 UTC 2022


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

          Issue ID: 22769
           Summary: `fun()` where fun is a property which returns an
                    object with opCall should call opCall
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

///////////////// test.d ////////////////
bool called;

struct S
{
    void opCall()
    {
        called = true;
    }
}

@property S fun()
{
    return S.init;
}

static assert(is(typeof(fun()) == void));
/////////////////////////////////////////

With @property, the () should be applied to the property return value.

To avoid suddenly breaking code, we can first deprecate and then hard-error on
expressions which are "ambiguous" in this way.

--


More information about the Digitalmars-d-bugs mailing list