About string and int spliced together.

Kagamin spam at here.lot
Sat Jun 20 06:36:37 UTC 2020


On Friday, 19 June 2020 at 10:57:42 UTC, Nick Treleaven wrote:
> On Thursday, 18 June 2020 at 14:24:40 UTC, Steven Schveighoffer 
> wrote:
>> On 6/18/20 10:04 AM, Stanislav Blinov wrote:
>>> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193
>>
>> Yikes. Let me rephrase.
>>
>> text is perfectly capable of avoiding this, and should, but 
>> for some reason doesn't.
>
> It used to call std.conv.toChars but that triggered a dmd 
> regression with a particular set of circumstances so it was 
> changed to use to!():
> https://github.com/dlang/phobos/pull/6659
>
> In bugzilla there was a better alternative workaround but no 
> one submitted a pull for that in time for the release:
> https://issues.dlang.org/show_bug.cgi?id=17712#c11
>
> I haven't been able to reproduce the test case with v2.092.0, 
> but maybe I'm doing something wrong.

I reduced it a but, but then it started to depend on the order of 
operations:

fail:

string test1()
{
	import std.uni : CodepointSet;
	import std.conv : to;
	uint a;
	CodepointSet charsets;
	string code = to!string(a);
	charsets.toSourceCode;
	return code;
}

success:

string test1()
{
	import std.uni : CodepointSet;
	import std.conv : to;
	uint a;
	CodepointSet charsets;
	charsets.toSourceCode;
	string code = to!string(a);
	return code;
}

Looks like it couldn't compare template instances well.


More information about the Digitalmars-d mailing list