[Issue 471] New: Protection attributes of mixin instances are applied in a wrong scope.
Ary Manzana
ary at esperanto.org.ar
Tue Oct 31 06:26:13 PST 2006
d-bugmail at puremagic.com escribió:
> http://d.puremagic.com/issues/show_bug.cgi?id=471
>
> Summary: Protection attributes of mixin instances are applied in
> a wrong scope.
> Product: D
> Version: 0.173
> Platform: PC
> OS/Version: Windows
> Status: NEW
> Keywords: rejects-valid, spec
> Severity: normal
> Priority: P4
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: brunodomedeiros+bugz at gmail.com
>
>
> Protection attributes of mixin instances are applied in a wrong scope.
> The following illustrates it:
> ---- baz.d ----
> module baz;
>
> template Baz() {
> private void privfunc(){ }
> }
> ---- ----
> import baz;
>
> class Foo {
> mixin Baz!();
>
> void testfunc() {
> privfunc(); // Error: .privfunc is private
> }
> }
> ---- ----
> For reference the spec states (http://www.digitalmars.com/d/mixin.html):
> "Unlike a template instantiation, a template mixin's body is evaluated within
> the scope where the mixin appears, not where the template declaration is
> defined. It is analogous to cutting and pasting the body of the template into
> the location of the mixin."
> If the current compiler behavior is the intended behavior then fix the spec.
>
>
This is what I was talking about in the "Is a template like copy-paste"
thread. Actually I was referring to copy-paste made by mixins.
Are the specs wrong?
More information about the Digitalmars-d-bugs
mailing list