[Issue 10373] New: cannot resolve forward reference (dmd2.063)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 16 02:16:39 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10373
Summary: cannot resolve forward reference (dmd2.063)
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: coz.d.lang at gmail.com
--- Comment #0 from coz.d.lang at gmail.com 2013-06-16 02:16:37 PDT ---
/**
* Main.d
*/
private import std.traits;
struct Test0(T, int N=0)
{
static if (N == 0) { T[] mBuffer; }
else { T[N] mBuffer; }
static if (is(T == class)){}
else
{
T* at_(size_t n) { return &mBuffer[n]; }
static if (is(typeof(*at_(0) = T.init)))
{ T opIndexAssign(T value, size_t index) { return (*at_(index) =
value); } }
}
}
struct Test1(T, int N=0)
{
static if (is(T == class)){}
else
{
T* at_(size_t n) { return &mBuffer[n]; }
static if (is(typeof(*at_(0) = T.init)))
{ T opIndexAssign(T value, size_t index) { return (*at_(index) =
value); } }
}
static if (N == 0) { T[] mBuffer; }
else { T[N] mBuffer; }
}
struct Test2(T, int N=0)
{
static if (is(T == class)){}
else
{
T* at_(size_t n) { return &mBuffer[n]; }
static if (std.traits.isMutable!T)
{ T opIndexAssign(T value, size_t index) { return (*at_(index) =
value); } }
}
static if (N == 0) { T[] mBuffer; }
else { T[N] mBuffer; }
}
void main()
{
static if (is(Test0!(int, 2))) pragma(msg, "Test0 is OK");
else pragma(msg, "Test0 is NG");
static if (is(Test1!(int, 2))) pragma(msg, "Test1 is OK");
else pragma(msg, "Test1 is NG");
static if (is(Test2!(int, 2))) pragma(msg, "Test2 is OK");
else pragma(msg, "Test2 is NG");
Test0!(int, 2) test0; // OK(dmd2.062) OK (dmd2.063)
Test1!(int, 2) test1; // OK(dmd2.062) NG (dmd2.063)
Test2!(int, 2) test2; // OK(dmd2.062) OK (dmd2.063)
/+ output dmd2.063
Test0 is OK
Main.d(24): Error: undefined identifier mBuffer
Test1 is NG
Test2 is OK
Main.d(24): Error: undefined identifier mBuffer
Main.d(49): Error: template instance Main.Test1!(int, 2) cannot resolve
forward reference
Main.d(26): Error: this for at_ needs to be type Test1 not type Test1
Main.d(55): Error: template instance Main.Test1!(int, 2) error
instantiating
+/
}
--
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