[Issue 9367] New: private in mixin template
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 22 03:00:56 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9367
Summary: private in mixin template
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: luka8088 at owave.net
--- Comment #0 from luka8088 <luka8088 at owave.net> 2013-01-22 03:00:53 PST ---
Upgrading to D v2.061 broke my code so I investigated and found inconsistent
behavior. The following example compiled in D v2.060:
// main.d
import foo;
void main () {
mixin m m1;
}
// foo.d
module foo;
private struct s {
int i;
}
mixin template m () {
s s1;
}
// foo.d(9): Error: module main foo.s is private
So I am not sure if this is a bug or was it a bug before, and there is actually
no any documentation for this specific case (that I could find). It only says
"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." so it could be understood that mixin template can
only see symbols from a scope that it is included in. On the other hand, if
that is the expected behavior, then the following code should not compile (at
least I think):
// main.d
import foo;
void main () {
mixin c.m m1;
}
// foo.d
module foo;
class b {
private struct s {
int i;
}
}
class c {
mixin template m () {
b.s s1;
}
}
Anyway, I think that the expected behavior in this cases should be better
documented.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list