[Issue 23921] New: The compiler is too pessimistic on how a double context might be required

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 13 17:22:33 UTC 2023


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

          Issue ID: 23921
           Summary: The compiler is too pessimistic on how a double
                    context might be required
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

The following code

```
class A
{
    void f()
    {
        class B : A
        {
            override void f()
            {
                class C : B
                {
                    override void f()
                    {
                        class D : C
                        {
                            override void f()
                            {
                            }
                        }

                        D abcd;
                    }
                }

                C abc;
            }
        }

        B ab;
    }
}
```

is rejected with

> A.f.B.f.C` is nested within `f`, but super class `B` is nested within `f`

But the very similar

```
class A
{
    void f()
    {
        static class B : A
        {
            override void f()
            {
                static class C : B
                {
                    override void f()
                    {
                        static class D : C
                        {
                            override void f()
                            {
                            }
                        }

                        D abcd;
                    }
                }

                C abc;
            }
        }

        B ab;
    }
}
```

is accepted.

--


More information about the Digitalmars-d-bugs mailing list