[Issue 7492] [CTFE] Error at assign to immutable character array
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Jan 20 09:09:14 PST 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=7492
Kenji Hara <k.hara.pg at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Denis Shelomovskij from comment #0)
> ---
> auto f() { return new char[1];  }
> 
> immutable s = f(); // error, works with non-character arrays
> ---
> Error: cannot implicitly convert expression ("\xff") of type char[] to
> immutable(char[])
The function returns char[]. In D type system, char[] to immutable(char[])
conversion is not allowed.
If you annotate the function f with pure attribute, f() will return an unique
array so compiler will allow the conversion.
Anyway, this is not CTFE problem. The code is trying to violate D type system,
and compiler reports the error correctly.
--
    
    
More information about the Digitalmars-d-bugs
mailing list