www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23451] New: Static function declared in with scope cannot


          Issue ID: 23451
           Summary: Static function declared in with scope cannot access
                    property on type alias in with expression type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

struct Foo {
    alias Bar = Object;

void main() {
    with (Foo()) {
        static void baz() {
            // this works
            auto a = new Bar;
            // this doesn't?
            auto b = Bar.classinfo;

DMD claims:

onlineapp.d(11): Error: `static` function `onlineapp.main.baz` cannot access
variable `__withSym` in frame of function `D main`

But it doesn't need the frame, because it's accessing a type alias, and it
knows this when doing `new Bar`, but somehow not when doing `Bar.classinfo`?

Nov 02 2022