File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1013,7 +1013,13 @@ if (!(is(S : T) &&
1013
1013
! isEnumStrToStr! (S, T) && ! isNullToStr! (S, T)) &&
1014
1014
! isInfinite! S && isExactSomeString! T)
1015
1015
{
1016
- static if (isExactSomeString! S && value[0 ].sizeof == ElementEncodingType! T.sizeof)
1016
+ static if (is (typeof (S.init.toString())) &&
1017
+ is (typeof (S.init.toString()) == string ) &&
1018
+ ! is (S == class ))
1019
+ {
1020
+ return value.toString();
1021
+ }
1022
+ else static if (isExactSomeString! S && value[0 ].sizeof == ElementEncodingType! T.sizeof)
1017
1023
{
1018
1024
// string-to-string with incompatible qualifier conversion
1019
1025
static if (is (ElementEncodingType! T == immutable ))
@@ -1121,6 +1127,19 @@ if (!(is(S : T) &&
1121
1127
return toStr! T(value);
1122
1128
}
1123
1129
}
1130
+ // https://issues.dlang.org/show_bug.cgi?id=24739
1131
+ @system unittest
1132
+ {
1133
+ import std.conv : to;
1134
+ import std.exception : enforce;
1135
+
1136
+ struct S
1137
+ {
1138
+ string toString () { return " S" ; }
1139
+ }
1140
+
1141
+ enforce(S.init.toString().ptr == S.init.to! string .ptr);
1142
+ }
1124
1143
1125
1144
// https://issues.dlang.org/show_bug.cgi?id=14042
1126
1145
@system unittest
You can’t perform that action at this time.
0 commit comments