[Issue 9705] property parameter-less template function not resolved in typeof

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 21 01:32:02 UTC 2017


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

Basile B. <b2.temp at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |b2.temp at gmx.com
          Component|phobos                      |dmd
         Resolution|---                         |INVALID

--- Comment #1 from Basile B. <b2.temp at gmx.com> ---
The specs say that typeof(F) gets the function F return type only when it's
marked @property.

(https://dlang.org/spec/declaration.html#typeof, §4)

When this rule is followed, the assertions are valid:

```
import std.range;

struct Infered
{
    size_t length()() @property {return 0;}
}

void main()
{
    Infered r;
    auto len = r.length; //OK
    static assert(hasLength!Infered); //OK
    static assert(is(typeof(r.length) : ulong)); //OK
    pragma(msg, typeof(r.length).stringof); //OK
}
```

--


More information about the Digitalmars-d-bugs mailing list