www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 49] New: Error instantiating a mixin with a private constructor

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=49

           Summary: Error instantiating a mixin with a private constructor
           Product: D
           Version: 0.149
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: daiphoenix lycos.com


The following gives a compiler error (as in the comented line):

  template Baz() {
    private this() {}
  }

  class Foo {
    mixin Baz!();  // Error: .this is private
  }


-- 
Mar 14 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=49


daiphoenix lycos.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Error instantiating a mixin |Protection attributes of
                   |with a private constructor  |mixin instances are applied
                   |                            |to a the wrong scope.




------- Comment #1 from daiphoenix lycos.com  2006-04-12 10:13 -------
Actually, this is part of the more general bug:
Protection attributes of mixin instances are applied to the wrong scope.
The following illustrates it:


  template Baz() {
    private void privfunc(){ }
    // private this() { }
  }

  class Foo {
    mixin Baz!();  

    void testfunc() {
        privfunc(); // Error: .privfunc is private
    }
  }


-- 
Apr 12 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=49


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com




------- Comment #2 from smjg iname.com  2006-05-18 08:42 -------
Actually, it isn't clearly defined.  It states:
"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."

This leaves open the question of where it's access-checked.  There was a
discussion on this a while back:

http://www.digitalmars.com/d/archives/digitalmars/D/bugs/3101.html


-- 
May 18 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=49





------- Comment #3 from daiphoenix lycos.com  2006-05-18 11:14 -------
(In reply to comment #2)
 Actually, it isn't clearly defined.  It states:
 "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."
 This leaves open the question of where it's access-checked.  There was a
 discussion on this a while back:
 http://www.digitalmars.com/d/archives/digitalmars/D/bugs/3101.html

In the very next sentenced it is said: "It is analogous to cutting and pasting the body of the template into the location of the mixin." which I think clears it up. Copy&Paste is the semantics I've been considering as the spec. (still, this doesn't say anything of whether this is or is not, the ideal language behavior.) --
May 18 2006
prev sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=49





------- Comment #4 from smjg iname.com  2006-05-18 11:37 -------
The key word is "analogous".  Not "identical".  The differences include several
of those listed here:

http://www.digitalmars.com/d/pretod.html#mixins

Did you even begin to read the thread I just linked to?

But even so, the testcases you have expose a different bug altogether, in which
access to private members within a module isn't always honoured.


-- 
May 18 2006
parent Bruno Medeiros <brunodomedeirosATgmail SPAM.com> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/bugzilla/show_bug.cgi?id=49
 
 
 
 
 
 ------- Comment #4 from smjg iname.com  2006-05-18 11:37 -------
 The key word is "analogous".  Not "identical".  The differences include several
 of those listed here:
 
 http://www.digitalmars.com/d/pretod.html#mixins
 
 Did you even begin to read the thread I just linked to?
 

Nope, I originally didn't read the thread (did now). The doc states (like you said): "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." I dunno how I missed this before, because I think the statement "a mixin's body is evaluated within the scope where the mixin appears" should be clear enough. The protection attributes are part of the body, and thus are "evaluated" where they appear. -- Bruno Medeiros - CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
May 20 2006