[Issue 23753] this allowed in static member function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 14 19:06:06 UTC 2023


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

Max Samukha <maxsamukha at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxsamukha at gmail.com

--- Comment #6 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to johanengelen from comment #3)

> 
> Yes, the language should have a clear structured grammar, rather than
> accepting hacks that appear convenient. See here for similar removal of
> hacky constructs: https://dlang.org/changelog/2.100.0.html#super_type_gone

I am not sure about that. There's been a long-standing tradition that allows
accessing static members via instance references.

struct S
{
    static void bar() {}
}

void main()
{
    S s;
    s.bar(); // works but could fail

    static void foo()
    {
        s.bar(); // fails but could work
    }
}

--


More information about the Digitalmars-d-bugs mailing list