www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 471] New: Protection attributes of mixin instances are applied in a wrong scope.

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: brunodomedeiros+bugz 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.


-- 
Oct 31 2006
next sibling parent Ary Manzana <ary esperanto.org.ar> writes:
d-bugmail 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 digitalmars.com
         ReportedBy: brunodomedeiros+bugz 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?
Oct 31 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=471


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 0.175


-- 
Nov 25 2006