[Issue 14170] `this` compiles in a static context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 14 13:25:51 UTC 2018


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
(1) is a case of DMD ignoring a redundant keyword - 'static' has no effect
there, so it's just ignored. It's been mentioned that this is due to static
blocks in aggregates, but I'm unsure of the exact details:

struct S {
    static { // or just static:
        // lots of declarations
        alias value this;
    }
}


(3) is explicitly mentioned in https://dlang.org/spec/declaration.html#typeof:

Special cases:

typeof(this) will generate the type of what this would be in a non-static
member function, even if not in a member function.


(2) and (4) are bug 6579. Possibly a bit more than that, since they don't have
an actual instance to work with, but that's the root.

--


More information about the Digitalmars-d-bugs mailing list