Bug 7663 – Mutable array of chars assigned to immutable fixed size array too

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-03-07T11:01:00Z
Last change time
2013-02-09T21:52:57Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-03-07T11:01:29Z
void main() { char[] a = "hello".dup; immutable char[4] s = a[0 .. 4]; } DMD 2.059head gives: test.d(3): Error: cannot implicitly convert expression (a[0u..4u]) of type char[] to const(immutable(char)[]) But I think it's easy to see the assignment is valid, even at compile-time.
Comment #1 by andrej.mitrovich — 2013-02-09T21:52:57Z
Fixed in 2.061.