#void main() {
# char[] t;
#// t ~= '我'; // Error: Can only append to dynamic arrays, not char[] ~= wchar
# t ~= "我";
# char[] r;
# foreach(dchar d; t) {
# int rel = r.length;
# r ~= d;
# if (d>127) assert(r.length-rel>1); // fails
# }
# assert(r.length == t.length); // fails
#}
First of all: since I'm allowed to write "r ~= dchar", I should also be allowed to do the same with a constant, '\u6211'. This probably got posted before.
The second one seems similar: it compiles without complaint, but it's not correctly appending the 2-byte dchar to the char[].
Comment #1 by smjg — 2006-04-21T08:20:14Z
Nothing like the error I get:
bugz111.d(3): unterminated character constant
bugz111.d(3): #line integer ["filespec"]\n expected
bugz111.d(3): unterminated character constant
bugz111.d(4): found 't' when expecting ';' following 'statement'
bugz111.d(4): found '~=' instead of statement
This is more understandable, since after the lexer has found one character, namely the '&', it expects the closing quote. However, it appears that the compiler is poor at recovering from this error.
Comment #2 by smjg — 2006-04-21T09:01:38Z
Having looked at the post on digitalmars.D.bugs from just before it was filed here, it now appears that either Bugzilla or the reporter's browser mangled the code. It was actually an oriental character embedded directly in the code. Let's see what happens if I try doing it in Mozilla....
# t ~= '我';
# t ~= "我";
Comment #3 by lio+bugzilla — 2006-04-21T09:15:01Z
Use '\u6211' resp. "\u6211" instead for the same effect.