[Issue 2706] New: invalid template instantiation (and declaration?) is not rejected
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 2 20:35:47 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2706
Summary: invalid template instantiation (and declaration?) is not
rejected
Product: D
Version: 1.033
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: tomas at famolsen.dk
The following code doesn't make sense to me, yet DMD accepts it:
module k;
enum TYP { ch, c }
class TypeBasic {
int oo;
/// Allocates an instance of TypeBasic and assigns it to typeName.
template newTB(char[] typeName)
{
const newTB = mixin("new TypeBasic(TYP."~typeName~")");
}
/// Initializes predefined types.
static this()
{
newTB!("c");
newTB!("ch");
}
this(int inp)
{
oo=inp;
}
}
void main()
{
}
I got this from a LDC bug report in IRC, and TBH I can't think anything but WTF
is going on here? DMD seems to emit two 'new' expressions in the static ctor.
I would think it should be:
error: 'new TypeBasic(TYP.c)' is not a constant expression
--
More information about the Digitalmars-d-bugs
mailing list