www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 111] New: appending a dchar to a char[]

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=111

           Summary: appending a dchar to a char[]
           Product: D
           Version: 0.154
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lio lunesu.com


#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[].


-- 
Apr 20 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=111


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com




------- Comment #1 from smjg iname.com  2006-04-21 08:20 -------
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.


-- 
Apr 21 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=111





------- Comment #2 from smjg iname.com  2006-04-21 09:01 -------
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 ~= "我";


-- 
Apr 21 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=111





------- Comment #3 from lio lunesu.com  2006-04-21 09:15 -------
Use '\u6211' resp. "\u6211" instead for the same effect.


-- 
Apr 21 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----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-----
May 01 2006