Error: cannot implicitly convert expression ("abcde") of type	invariant char[5u] to char[]
    torhu 
    no at spam.invalid
       
    Wed Sep  5 12:01:44 PDT 2007
    
    
  
Tom McMurray wrote:
> I just downloaded version 2.003 or DMD and tried to compile the following :-
> 
> class stringtest
> {
>    void st1()
>    {
>        char[] s1 = "abcde";
>    }
> }
> 
> This fails with the error :-
> 
> Error: cannot implicitly convert expression ("abcde") of type invariant char[5u] to char[]
> 
> Is this a bug or am I doing something stupid.  This code compiled successfully on previous versions of the compiler.  Any help would be appreciated
Try 'string' instead of 'char[]'.  String is an alias for 
'const(char)[]', which an 'invariant char[5u]' can be implicitly 
converted to.
And I wouldn't write too much code for D 2.0 just yet, things might 
change.  There was even talk of changing the const stuff.
    
    
More information about the Digitalmars-d-learn
mailing list