[Issue 17239] template this in typeof expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 14 19:26:27 UTC 2022


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

John Colvin <john.loughran.colvin at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #4 from John Colvin <john.loughran.colvin at gmail.com> ---
(In reply to Nick Treleaven from comment #2)
> >     @property int b(this X)() { return 2; }
> 
> If you change b above to c (I assume it's a typo), you get:
> 
> int
> int()
> void
> 
> As c is a template, the type is supposed to be void. This is nothing to do
> with the template this parameter.

Yes, a typo.

I suppose that means this is a wontfix. typeof is weird, e.g.

typeof(a.b) c = a.b;

doesn’t actually work generically (aside from copy-ability concerns). I
understand why it is this way, but it would be nice if the docs actually
explained what it was supposed to do.

The type of an expression is… well it depends what that expression part of. The
“Full Expression” section is not very enlightening.

--


More information about the Digitalmars-d-bugs mailing list