Bug 9251 – An immutable arrays concatenation to produce an immutable implicitly castable to mutable?

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-01T08:47:00Z
Last change time
2013-01-04T23:32:00Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-01-01T08:47:30Z
void main() { string s1 = "abc"; char[] s2 = s1 ~ s1; } DMD 2.061alpha gives: test.d(3): Error: cannot implicitly convert expression (s1 ~ s1) of type string to char[] A concatenation allocates a new array, so I think it should be a strongly pure operation. So maybe a string concatenation should return a string that's implicitly castable to char[]. (While usually in D with purity you have mutable things that are implicitly castable to immutable). Is this possible and safe?
Comment #1 by yebblies — 2013-01-04T23:32:00Z
*** This issue has been marked as a duplicate of issue 1654 ***