111 – appending a dchar to a char[]

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 111 - appending a dchar to a char[]
Summary: appending a dchar to a char[]
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
: 914 (view as issue list)
Depends on:
Blocks:
Reported: 2006年04月20日 09:47 UTC by Lionello Lunesu
Modified: 2014年02月15日 13:19 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Lionello Lunesu 2006年04月20日 09:47:09 UTC
#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 Stewart Gordon 2006年04月21日 08:20:14 UTC
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 Stewart Gordon 2006年04月21日 09:01:38 UTC
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 Lionello Lunesu 2006年04月21日 09:15:01 UTC
Use '\u6211' resp. "\u6211" instead for the same effect.
Comment 4 Thomas Kühne 2006年05月01日 04:15:20 UTC
-----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-----
Comment 5 Oskar Linde 2007年02月01日 15:59:14 UTC
*** Bug 914 has been marked as a duplicate of this bug. ***
Comment 6 Walter Bright 2009年12月06日 00:43:32 UTC
Fixed dmd 1.053 and 2.037


AltStyle によって変換されたページ (->オリジナル) /