Is this a bug in std.typecons.Tuple.slice?

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 6 18:35:01 PST 2016


On Sunday, 7 February 2016 at 02:11:15 UTC, Marco Leise wrote:
> Why do I insist on the return type? Because surprisingly simple 
> code breaks if it doesn't match. Not everything can be covered 
> by runtime conversions in D. It still took me a while to come 
> up with something obvious:
>
> 	uint[Tuple!(uint, ulong)] hash;
>
> 	auto tup = tuple(1u, 2u, 3UL);
>
> 	hash[tup.slice!(1, 3)] = tup[0];
>
>                      compiles?  works?
> original Tuple     : yes        no
> Saurabh Das changes: yes        yes
> your changes       : no         no

Thank you for the example.

If multiple alias this ever makes it into the language (see 
https://wiki.dlang.org/DIP66 and 
https://github.com/D-Programming-Language/dmd/pull/3998), this 
could be fixed quite easily. But, I do not see any way to fix it 
with the tools currently available.


More information about the Digitalmars-d-learn mailing list