Mercurial > projects > dstress
changeset 1357:b1b781fac9a5
[Issue 874] Incorrect codegen (?) with tuples, string constants, and AAs
Jarrett Billingsley <jarrett.billingsley@gmail.com>
2007-01-22
http://d.puremagic.com/issues/show_bug.cgi?id=874
author | thomask |
---|---|
date | Fri, 23 Feb 2007 22:34:28 +0000 |
parents | 36032afb4652 |
children | 4d5d9a6439e2 |
files | run/o/odd_bug_13_A.d |
diffstat | 1 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/o/odd_bug_13_A.d Fri Feb 23 22:34:28 2007 +0000 @@ -0,0 +1,38 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Jarrett Billingsley <jarrett.billingsley@gmail.com> +// @date@ 2007-01-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=874 +// @desc@ [Issue 874] Incorrect codegen (?) with tuples, string constants, and AAs + +module dstress.run.o.odd_bug_13_A; + +template AA(V, K){ + V[K] AA(T...)(T args){ + V[K] ret; + K key; + + foreach(i, arg; args){ + if(!(i & 1)){ + key = arg; + }else{ + ret[key] = arg; + } + } + + assert(2 == ret.length); + assert("b" == ret["a"]); + assert("d" == ret["c"]); + return ret; + } +} + +int main(){ + char[][char[]] array = AA!(char[], char[])("a", "b", "c", "d"); + assert(2 == array.length); + assert("b" == array["a"]); + assert("d" == array["c"]); + return 0; +}