digitalmars.D.learn - Assert prints an "array of char" when used why to!string
- "monarch_dodra" <monarchdodra gmail.com> Jul 27 2012
- "bearophile" <bearophileHUGS lycos.com> Jul 27 2012
- "novice2" <sorry noem.ail> Jul 27 2012
- "Adam D. Ruppe" <destructionator gmail.com> Jul 27 2012
- "novice2" <sorry noem.ail> Jul 27 2012
- "monarch_dodra" <monarchdodra gmail.com> Jul 27 2012
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
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
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: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.
Jul 27 2012









=?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> 