www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21908] New: protected struct static opCall from mixin

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

          Issue ID: 21908
           Summary: protected struct static opCall from mixin template not
                    available from child class
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: destructionator gmail.com

file mix2.d:

---
class C {
        mixin Signal foo;

        protected struct protstruct {}
}

mixin template Signal() {
        final:
        protected struct emit {
                static void opCall() {}
        };
        public struct connect {
                static void opCall() {}
        };
}
---

file mix.d:

---
import mix2;
void main() {
        auto d = new D;

        //d.foo.emit(); // correctly hidden because it is protected (though the
error message is not great, it isn't wrong)
        d.foo.connect(); // it is public so this works

        d.bar.emit(); // this is ok because it our same module
        d.bar.connect(); // again public so we're ok

        //C.protstruct not_available; // correctly hidden because it is
protected
}

class D : C {
        this() {
                // no trouble off the one here
                bar.emit();
                bar.connect();

                protstruct available; // protected works just fine as it should

                foo.emit actually_works; // the symbol isn't just hidden...

                foo.connect(); // public off the other one works ok
                // and BUG here
                foo.emit(); // but the protected one is not letting me call it
        }

        mixin Signal bar;
}
---


That foo.emit should be the same as the protstruct, but instead it says:

mix.d(27): Error: no property `emit` for type `void`


It shouldn't be saying "type void" at all, making me pretty sure this is a bug.
And it works if i do the static opCall thing on protstruct too - surely the
mixin template should behave the same way.

--
May 08