[Issue 995] New: compile-time function return element of Tuple / const array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 22 04:40:20 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=995
Summary: compile-time function return element of Tuple / const
array
Product: D
Version: 1.007
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: Daniel919 at web.de
compile-time function return element of Tuple
--------------------------------------------------------------------
import std.stdio;
template Tuple(A...) { alias A Tuple; }
template eval(A...) { alias A eval; }
alias Tuple!("a","b") foo;
char[] retsth(int i) { return foo[i]; }
//Error: Integer constant expression expected instead of cast(uint)i
void main()
{
writefln(eval!(foo[0]));
//this is working
writefln(eval!(retsth(0)));
}
--------------------------------------------------------------------
compile-time function return element of const array
--------------------------------------------------------------------
import std.stdio;
template eval(A...) { alias A eval; }
const char[] foo[2] = ["a","b"];
char[] retsth(int i) { return foo[i]; }
void main()
{
writefln(eval!(foo[0]));
//this is working (see #975)
writefln(eval!(retsth(0)));
//but this makes dmd crash
}
--------------------------------------------------------------------
--
More information about the Digitalmars-d-bugs
mailing list