| Thread overview | |||||||||
|---|---|---|---|---|---|---|---|---|---|
|
July 27, 2012 Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Code:
----
import std.conv;
void main() {
static assert(
is(typeof(("Failure: " ~ to!string(55)) == string))
);
static assert(0 , ("Failure: " ~ to!string(55)));
}
----
main.d(7): Error: static assert ['F','a','i','l','u','r','e',':',' ','5','5']
----
The problem is the ugly-ass "print as array of individual characters".
I really don't understand what is going on, since the compile type of my string is indeed "string".
If I remove the "to!string", I get:
----
main.d(7): Error: static assert "Failure"
----
1) Is this the "normal" behavior, or a "known limitation"?
2) Is there a "workaround"?
FYI, this was originally produced by code from Phobos, but was trimmed by me here.
| ||||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | monarch_dodra: > 1) Is this the "normal" behavior, or a "known limitation"? It seems a DMD bug, why don't you add it to Bugzilla? > 2) Is there a "workaround"? static assert(0, text("Failure: ", 55)); Bye, bearophile | |||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | BTW, in docs about "text": http://dlang.org/phobos/std_conv.html#text "...Convenience functions for converting any number and types of arguments into text (the three character widths)... " What is the "three character widths" note? Who knows? | |||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to novice2 | On Friday, 27 July 2012 at 14:40:33 UTC, novice2 wrote:
> What is the "three character widths" note?
> Who knows?
string, wstring, and dstring. Width refers to the bit size
of the char (8 bit, 16 bit, or 32 bit).
| |||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | Ah, thanks!
On Friday, 27 July 2012 at 14:47:49 UTC, Adam D. Ruppe wrote:
> On Friday, 27 July 2012 at 14:40:33 UTC, novice2 wrote:
>> What is the "three character widths" note?
>> Who knows?
>
> string, wstring, and dstring. Width refers to the bit size
> of the char (8 bit, 16 bit, or 32 bit).
| |||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Friday, 27 July 2012 at 11:56:07 UTC, bearophile wrote:
> monarch_dodra:
>
>> 1) Is this the "normal" behavior, or a "known limitation"?
>
> It seems a DMD bug, why don't you add it to Bugzilla?
>
>
>> 2) Is there a "workaround"?
>
> static assert(0, text("Failure: ", 55));
>
> Bye,
> bearophile
Thanks. I'll create an entry in bugzilla.
| |||
July 27, 2012 Re: Assert prints an "array of char" when used why to!string | ||||
|---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | On 07/27/2012 09:02 AM, monarch_dodra wrote:
> On Friday, 27 July 2012 at 11:56:07 UTC, bearophile wrote:
>> monarch_dodra:
>>
>>> 1) Is this the "normal" behavior, or a "known limitation"?
>>
>> It seems a DMD bug, why don't you add it to Bugzilla?
>>
>>
>>> 2) Is there a "workaround"?
>>
>> static assert(0, text("Failure: ", 55));
>>
>> Bye,
>> bearophile
>
> Thanks. I'll create an entry in bugzilla.
Thanks. I hope that will fix the Unicode ignorance of 'static assert' as well:
static assert(false, "aüz");
produces the following output:
Error: static assert "a\xc3\xbcz"
Ali
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply