digitalmars.D.bugs - [Issue 995] New: compile-time function return element of Tuple / const array
- d-bugmail puremagic.com (43/43) Feb 22 2007 http://d.puremagic.com/issues/show_bug.cgi?id=995
- d-bugmail puremagic.com (23/23) Feb 22 2007 http://d.puremagic.com/issues/show_bug.cgi?id=995
- d-bugmail puremagic.com (12/12) Feb 26 2007 http://d.puremagic.com/issues/show_bug.cgi?id=995
- d-bugmail puremagic.com (6/6) Mar 09 2007 http://d.puremagic.com/issues/show_bug.cgi?id=995
- d-bugmail puremagic.com (9/9) Mar 19 2007 http://d.puremagic.com/issues/show_bug.cgi?id=995
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 digitalmars.com
ReportedBy: Daniel919 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]));
writefln(eval!(retsth(0)));
//but this makes dmd crash
}
--------------------------------------------------------------------
--
Feb 22 2007
http://d.puremagic.com/issues/show_bug.cgi?id=995
Is this related to the bug ?
--------------------------------------------------------------------
import std.stdio;
template eval(A...) { alias A eval; }
char[] retsth(int i) {
const char[] foo[2] = ["a","b"];
return foo[i];
}
//Error: cannot evaluate retsth(0) at compile time
//Error: expression eval!(retsth(0)) is void and has no value
void main()
{
writefln(eval!(retsth(0)));
}
--------------------------------------------------------------------
PS: Ultimately I would like to be able to do:
writefln(eval!(std.string.stripl(" test"));
Maybe some more string operations could be compile-time ready ?
I am not sure whether this will work if this bug get's fixed,
so maybe this is a feature req ;)
--
Feb 22 2007
http://d.puremagic.com/issues/show_bug.cgi?id=995
thomas-dloop kuehne.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|Windows |All
Added to DStress as
http://dstress.kuehne.cn/run/t/tuple_16_A.d
http://dstress.kuehne.cn/run/t/tuple_16_B.d
http://dstress.kuehne.cn/run/t/tuple_16_C.d
http://dstress.kuehne.cn/run/t/tuple_16_D.d
--
Feb 26 2007
http://d.puremagic.com/issues/show_bug.cgi?id=995 The first example is not a bug; tuples must be evaluatable at compile time, and i of retsth(i) is not known at compile time when object code is generated for it. The other two are bugs. --
Mar 09 2007
http://d.puremagic.com/issues/show_bug.cgi?id=995
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed DMD 1.009
--
Mar 19 2007









d-bugmail puremagic.com 