diff --git a/std/conv.d b/std/conv.d index 2e2c7342abd..6df3bd0b24d 100644 --- a/std/conv.d +++ b/std/conv.d @@ -917,9 +917,22 @@ if (!is(S : T) && auto result = ()@trusted{ return cast(T) value; }(); if (!result && value) { - throw new ConvException("Cannot convert object of static type " - ~S.classinfo.name~" and dynamic type "~value.classinfo.name - ~" to type "~T.classinfo.name); + string name(TypeInfo ti) @trusted + { + while (auto tc = (cast(TypeInfo_Const) ti)) + { + ti = tc.base; + } + if (auto tinf = (cast(TypeInfo_Interface) ti)) + { + ti = tinf.info; + } + TypeInfo_Class tc = cast(TypeInfo_Class) ti; + assert(tc); + return tc.name; + } + throw new ConvException("Cannot convert object of static type " ~ + name(typeid(S)) ~ " and dynamic type " ~ name(typeid(value)) ~ " to type " ~ name(typeid(T))); } return result; }