Bug 8028 – Templates sometimes-can/sometimes-can't access private symbols in same module
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-03T17:16:00Z
Last change time
2014-08-18T18:51:08Z
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2012-05-03T17:16:53Z
----------------------
// test1.d
import test2;
auto a = foo!1;
----------------------
// test2.d
template foo(int i)
{
immutable foo = makeStruct(i); // A
//immutable foo = MyStruct(i); // B
}
private MyStruct makeStruct(int i)
{
return MyStruct(i);
}
struct MyStruct
{
private this(int i) {}
}
----------------------
In test2.d, using the line marked "A" compiles successfully, but using the line marked "B" results in:
Error: struct test2.MyStruct member this is not accessible
I don't know whether they're supposed to both succeed or both fail, but that fact that one works and the other doesn't sounds like a compiler bug to me.
Comment #1 by hsteoh — 2014-08-18T18:51:08Z
Seems to have been fixed in latest git HEAD. Both A and B are now accepted.