blob: 86d3f9185d5a329b38fe5e52fbe1356eaff40e68 [file] [log] [blame]
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96152
// { dg-additional-options "-fmain -funittest" }
// { dg-do run }
// { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
auto assocArray(Keys, Values)(Keys keys, Values values)
{
void* aa;
{
if (values.length > keys.length)
values = values[0 .. keys.length];
else if (keys.length > values.length)
keys = keys[0 .. values.length];
aa = aaLiteral(keys, values);
}
alias Key = typeof(keys[0]);
alias Value = typeof(values[0]);
return (() @trusted => cast(Value[Key]) aa)();
}
@safe unittest
{
struct ThrowingElement
{
int i;
static bool b;
~this(){
if (b)
throw new Exception("");
}
}
assert(assocArray([ThrowingElement()], [0]) == [ThrowingElement(): 0]);
}