D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7313 - the result of a 'new' expression should implicitly cast to (im)mutable
Summary: the result of a 'new' expression should implicitly cast to (im)mutable
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-18 11:20 UTC by timon.gehr
Modified: 2017-08-07 22:24 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-01-18 11:20:40 UTC
the following code should compile:
void main(){
    immutable a = new int[1];
    int[] b = new immutable(int)[1];
}
Comment 1 Jonathan M Davis 2012-01-18 13:56:46 UTC
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 timon.gehr 2012-01-18 14:28:35 UTC
It works with any type that has a pure constructor where all (unscoped) constructor arguments convert to the respective qualifier.
Comment 3 ag0aep6g 2017-08-07 22:24:16 UTC
(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.