digitalmars.D.learn - Assert prints an "array of char" when used why to!string
- monarch_dodra (25/25) Jul 27 2012 Code:
- bearophile (5/7) Jul 27 2012 static assert(0, text("Failure: ", 55));
- novice2 (6/6) Jul 27 2012 BTW, in docs about "text":
- Adam D. Ruppe (3/5) Jul 27 2012 string, wstring, and dstring. Width refers to the bit size
- novice2 (2/7) Jul 27 2012
- monarch_dodra (2/9) Jul 27 2012 Thanks. I'll create an entry in bugzilla.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/22) Jul 27 2012 Thanks. I hope that will fix the Unicode ignorance of 'static assert' as...
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.
Jul 27 2012
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
Jul 27 2012
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?
Jul 27 2012
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).
Jul 27 2012
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).
Jul 27 2012
On Friday, 27 July 2012 at 11:56:07 UTC, bearophile wrote:monarch_dodra:Thanks. I'll create an entry in bugzilla.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
Jul 27 2012
On 07/27/2012 09:02 AM, monarch_dodra wrote:On Friday, 27 July 2012 at 11:56:07 UTC, bearophile wrote: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" Alimonarch_dodra:Thanks. I'll create an entry in bugzilla.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
Jul 27 2012