Bug 111 – appending a dchar to a char[]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-04-20T09:47:00Z
Last change time
2014-02-15T13:19:57Z
Keywords
rejects-valid
Assigned to
nobody
Creator
lio+bugzilla

Comments

Comment #0 by lio+bugzilla — 2006-04-20T09:47:09Z
#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.
Comment #4 by thomas-dloop — 2006-05-01T04:15:20Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] 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-----
Comment #5 by oskar.linde — 2007-02-01T15:59:14Z
*** Bug 914 has been marked as a duplicate of this bug. ***
Comment #6 by bugzilla — 2009-12-06T00:43:32Z
Fixed dmd 1.053 and 2.037