CTFE output is kind of weired

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 8 14:29:10 PDT 2017


Hi,

I use assert(false, tmp) to see the content of variable tmp as it 
seems there is no other way in CTFE.

The output is kind of weired:
app.d(6): Error: "1234\x0a5678\x0a"[4..10]
app.d(17):        called from here: test("1234\x0a5678\x0a")

I wrote the source code on windows with a source file with \r\n 
file endings.
But the console output has only the character X0a.
In addition not the content of tmp is shown but the full content 
with the slice information [4..10].

Is this the intented behavior?

string test(string s)
{
     string tmp = s;
     tmp = tmp[4..$];
     assert(false, tmp);
     return tmp;
}

enum foo =
`1234
5678
`;

void main()
{
     enum bar = test(foo);
}

Kind regards
André


More information about the Digitalmars-d-learn mailing list