[Issue 21886] New: case where member function used as "alias this sym" is allowed without right `this` context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 2 01:40:23 UTC 2021


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

          Issue ID: 21886
           Summary: case where member function used as "alias this sym" is
                    allowed without right `this` context
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

This code compiles and runs.

---
struct D
{
    static int a;
}

struct C
{
    int h;
    D get()
    {
        assert(h);
        assert(false);
    }
    alias get this;
}

void main(string[] args)
{
    if (C.a){}
} 
---

get() is not executed but in first place that should not compile as in C.a
there's not valid this context.

--


More information about the Digitalmars-d-bugs mailing list