#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[].
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.
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 ~= "我";
Use '\u6211' resp. "\u6211" instead for the same effect.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail@puremagic.com schrieb am 2006年04月20日: > 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[]. Added to DStress as http://dstress.kuehne.cn/run/o/opCatAssign_19_A.d http://dstress.kuehne.cn/run/o/opCatAssign_19_B.d http://dstress.kuehne.cn/run/o/opCatAssign_19_C.d http://dstress.kuehne.cn/run/o/opCatAssign_19_D.d http://dstress.kuehne.cn/run/o/opCatAssign_19_E.d http://dstress.kuehne.cn/run/o/opCatAssign_19_F.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEVdsl3w+/yD4P9tIRAm/FAJ4rgRSTRRwbVmPXtYVpcYHlIXRKvgCbBUoj 7ZXw1fdDfWTN0OQaWo+zYf4= =5q3X -----END PGP SIGNATURE-----
*** Bug 914 has been marked as a duplicate of this bug. ***
Fixed dmd 1.053 and 2.037
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル