view run/o/odd_bug_13_A.d @ 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
children ac560364010c
line wrap: on
line source

// $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;
}