D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11387 - Tuple of dynamic array literal can't be immutable
Summary: Tuple of dynamic array literal can't be immutable
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: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-10-30 12:35 UTC by bearophile_hugs
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-10-30 12:35:33 UTC
A low-priority enhancement suggestion:


import std.typecons: tuple;
void main() {
    immutable t = tuple([1, 2]);
}


dmd 2.064beta3 gives:

test.d(3): Error: cannot implicitly convert expression (tuple([1, 2])) of type Tuple!(int[]) to immutable(Tuple!(int[]))

I presume built-in tuples could do this too.

To do this with Phobos-defined tuples, there should be a way to know that the input dynamic array is pure. I don't know if and how this can be done.