Bug 14056 – std.array.assocArray with a const value

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2015-01-27T01:39:00Z
Last change time
2015-03-20T02:13:59Z
Keywords
pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2015-01-27T01:39:31Z
This seems a regression, this used to work: void main() { import std.array: assocArray; import std.typecons: Tuple; Tuple!(int, immutable(char))[] a1; immutable(char)[int] aa = assocArray(a1); } Dmd 2.067alpha gives: test.d(5,41): Error: template std.array.assocArray cannot deduce function from argument types !()(Tuple!(int, immutable(char))[]), candidates are: ...\dmd2\src\phobos\std\array.d(326,6): std.array.assocArray(Range)(Range r) if (isInputRange!Range && ElementType!Range.length == 2 && isMutable!(ElementType!Range.Types[1]))
Comment #1 by kuettler — 2015-02-17T20:32:37Z
This seems to be a conscious choice, the function has been restricted to prevent a compile failure on assignment. The question is how to create associative array with immutable values.
Comment #2 by kuettler — 2015-02-17T20:39:06Z
Same as Issue 13909.
Comment #3 by code — 2015-02-19T02:03:10Z
(In reply to Ulrich Küttler from comment #1) > This seems to be a conscious choice, the function has been restricted to > prevent a compile failure on assignment. The question is how to create > associative array with immutable values. You know where it was introduced? We shouldn't switch from working to not-working without a deprecation phase.
Comment #4 by kuettler — 2015-02-19T09:13:04Z
(In reply to Martin Nowak from comment #3) > You know where it was introduced? We shouldn't switch from working to > not-working without a deprecation phase. Unfortunately not, I do not know what changed here.
Comment #5 by k.hara.pg — 2015-03-01T05:10:04Z
(In reply to Martin Nowak from comment #3) > (In reply to Ulrich Küttler from comment #1) > > This seems to be a conscious choice, the function has been restricted to > > prevent a compile failure on assignment. The question is how to create > > associative array with immutable values. > > You know where it was introduced? We shouldn't switch from working to > not-working without a deprecation phase. Introduced by the fix for regression 13701.
Comment #6 by bugzilla — 2015-03-14T05:29:42Z
(In reply to Kenji Hara from comment #5) > Introduced by the fix for regression 13701. https://issues.dlang.org/show_bug.cgi?id=13701 https://github.com/D-Programming-Language/dmd/pull/4148
Comment #7 by code — 2015-03-15T16:32:17Z