www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Bug: string cast overrides string decorator

reply Bruno Medeiros <daiphoenixNO SPAMlycos.com> writes:
In the following code:

   auto str = cast(wchar[])("123456"c);
   writefln(typeid(typeof(str)));
   writefln("str: ", (cast(char[])str).length,": ", (cast(char[])str));

the (original) string literal will be of type wchar[$] and not char[$], 
as the cast takes precedence over the string decorator.


-- 
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to 
be... unnatural."
Nov 18 2005
parent Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
Bruno Medeiros wrote:
 In the following code:
 
   auto str = cast(wchar[])("123456"c);
   writefln(typeid(typeof(str)));
   writefln("str: ", (cast(char[])str).length,": ", (cast(char[])str));
 
 the (original) string literal will be of type wchar[$] and not char[$], 
 as the cast takes precedence over the string decorator.
 
 
How is that a bug? The type of the right side is wchar[]. auto x = cast(float)4; x is float, not int, same thing above.
Nov 18 2005