digitalmars.D.learn - A tuple bug?
- Max Samukha (27/27) Apr 23 2007 The output when compiling the code below is "1, 1" while it should be
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (19/23) Apr 23 2007 Yeah, something fishy is happening here (tested with dmd 1.013). This co...
- Max Samukha (3/26) Apr 24 2007 Thanks. I've posted this to bugzilla
The output when compiling the code below is "1, 1" while it should be "1, 2". When 'names' declarations are commented out, the output is correct. import std.stdio; template Foo(A...) { static if (A.length > 3) { const char[] names = A[0] ~ ", " ~ Foo!(A[3..$]).names; const char[] values = A[1].stringof ~ ", " ~ Foo!(A[3..$]).values; } else { static assert(A.length == 3); const char[] names = A[0]; const char[] values = A[1].stringof; } } void main() { pragma(msg, Foo!( "One", 1, "First item", "Two", 2, "Second item").values ); } Is it a bug?
Apr 23 2007
Max Samukha wrote:The output when compiling the code below is "1, 1" while it should be "1, 2". When 'names' declarations are commented out, the output is correct.<snip>Is it a bug?Yeah, something fishy is happening here (tested with dmd 1.013). This code template Foo(A...) { const char[] values = A[1].stringof; pragma(msg, A.length.stringof); // 1) pragma(msg, values); } void main() { alias Foo!(1,1,1,1,1) val; } returns 5 5 but commenting the line 1) makes it return '1'. Also the compiler should be able to infer the type of 'values' when 'char[]' is omitted, but it doesn't. So, at least two bugs here.
Apr 23 2007
On Mon, 23 Apr 2007 23:42:37 +0300, Jari-Matti Makela <jmjmak utu.fi.invalid> wrote:Max Samukha wrote:Thanks. I've posted this to bugzillaThe output when compiling the code below is "1, 1" while it should be "1, 2". When 'names' declarations are commented out, the output is correct.<snip>Is it a bug?Yeah, something fishy is happening here (tested with dmd 1.013). This code template Foo(A...) { const char[] values = A[1].stringof; pragma(msg, A.length.stringof); // 1) pragma(msg, values); } void main() { alias Foo!(1,1,1,1,1) val; } returns 5 5 but commenting the line 1) makes it return '1'. Also the compiler should be able to infer the type of 'values' when 'char[]' is omitted, but it doesn't. So, at least two bugs here.
Apr 24 2007