[Issue 21870] New: Property/method not invoked and requires () when used in static array length

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 28 01:08:37 UTC 2021


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

          Issue ID: 21870
           Summary: Property/method not invoked and requires () when used
                    in static array length
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

////////////////////////////// test.d /////////////////////////////
struct S
{
    @property size_t count() const
    {
        return 1;
    }
}

int[S.init.count()] x; // OK
int[S.init.count  ] y; // error
// Error: need `this` for `count` of type `const @property ulong()`
///////////////////////////////////////////////////////////////////

Additionally, the error message is misleading. Older versions of compilers
produced a better error:

2.079.0 to 2.087.1: Failure with output: test.d(9): Error: integer constant
expression expected instead of `S().count`

--


More information about the Digitalmars-d-bugs mailing list