Bug 581 – Error message w/o line number in dot-instantiated template
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-21T08:40:00Z
Last change time
2014-02-15T13:21:45Z
Keywords
diagnostic
Assigned to
bugzilla
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2006-11-21T08:40:27Z
I had trouble cutting this one down, subtle changes will make the bug disappear; but probably this test case is far more complex than necessary.
Output:
-----------
3bug20__T4MangS9_Dmain
Error: cannot cast int to char[]
Error: non-constant expression cast(char[])0
Note: for this test, filename must be exactly 3 letters long, eg "bug.d"
--------
template Mang(alias F)
{
enum H { ignore }
alias void function (H ) G;
const char [] J = typeof(G).mangleof[3..$-8];
}
template X(){}
template D(char [] str){}
template A(char [] str)
{
static if (str.length==22)
const char [] A = str;
else static if (str[4]<='9')
const char [] A = A!(str[4..$]);
else static if (D!(str[str]))
{}
else const char [] A = .X!();
}
template M(alias B)
{
const char [] M = A!(Mang!(B).J);
}
void main()
{
int q = 3;
pragma(msg, M!(q));
}
--------
Comment #1 by clugdbug — 2008-01-02T09:13:40Z
I cut this example down a lot - to one line in fact!
It's the . in the template instantiation that triggers it.
---------------------------
static assert(.a!().b);
---------------------------
Output:
-----------
bug.d(15): Error: template identifier a is not a member of module bug
Error: no property 'b' for type 'int'
--------