Bug 49 – Protection attributes of mixin instances are applied to a the wrong scope.

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-03-14T11:47:00Z
Last change time
2014-02-15T02:10:03Z
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2006-03-14T11:47:55Z
The following gives a compiler error (as in the comented line): template Baz() { private this() {} } class Foo { mixin Baz!(); // Error: .this is private }
Comment #1 by bruno.do.medeiros+deebugz — 2006-04-12T10:13:46Z
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 } }
Comment #2 by smjg — 2006-05-18T08:42:04Z
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
Comment #3 by bruno.do.medeiros+deebugz — 2006-05-18T11:14:49Z
(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.)
Comment #4 by smjg — 2006-05-18T11:37:03Z
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.
Comment #5 by bruno.do.medeiros+deebugz — 2006-10-31T08:01:01Z
This one is outdated, updated to bug #471