Bug 7313 – the result of a 'new' expression should implicitly cast to (im)mutable
Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-18T11:20:00Z
Last change time
2017-08-07T22:24:16Z
Assigned to
nobody
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2012-01-18T11:20:40Z
the following code should compile:
void main(){
immutable a = new int[1];
int[] b = new immutable(int)[1];
}
Comment #1 by issues.dlang — 2012-01-18T13:56:46Z
I can see why that would be nice with regards to primitives, but I would point out that that wouldn't work with structs or classes (or with arrays of structs or classes).
Comment #2 by timon.gehr — 2012-01-18T14:28:35Z
It works with any type that has a pure constructor where all (unscoped) constructor arguments convert to the respective qualifier.
Comment #3 by ag0aep6g — 2017-08-07T22:24:16Z
(In reply to timon.gehr from comment #0)
> the following code should compile:
> void main(){
> immutable a = new int[1];
> int[] b = new immutable(int)[1];
> }
Works now (dmd 2.075) and has been working for a while. Closing as WORKSFORME.