Summary: typeof() for member functions evaluated incorrectly
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

// Copied/pasted from std.range, added pragma.
template hasLength(R)
    pragma(msg, typeof(R.init.length).stringof);  // (uint())()
    enum bool hasLength = is(typeof(R.init.length) : ulong);

struct Foo {
    uint length() {
        return 0;

const Foo foo;

static assert(hasLength!(Foo));  // Fails.

This is pretty serious because it makes important functionality in the new
Phobos unusable.  However, an easy workaround to fix Phobos until the
underlying DMD bug gets fixed is:

enum bool hasLength = is(typeof(R.init.length) : ulong) ||
                      is(typeof(R.init.length()) : ulong);

Also, what the heck is a (uint())() ?


Reply via email to