[Issue 13909] New: A problem with immutable zip + assocArray
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Dec 29 04:46:10 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13909
Issue ID: 13909
Summary: A problem with immutable zip + assocArray
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I don't understand what's going on here. The line where aa2 is initialized gets
accepted, while the initialization of aa5 gets refused, despite in both cases
they use zipped keys/values from immutable associative arrays:
import std.array: assocArray;
import std.range: zip;
immutable string[const string] aa1, aa2, aa4, aa5;
static this() pure {
immutable aa3 = ["a":"b"];
aa2 = aa3.byValue.zip(aa3.byKey).assocArray; // OK
aa4 = ["a":"b"];
aa5 = aa4.byValue.zip(aa4.byKey).assocArray; // Error
}
void main() {}
dmd 2.067alpha gives:
...\dmd2\src\phobos\std\array.d(281,11): Error: cannot modify const expression
aa[t.__expand_field_0]
test.d(8,37): Error: template instance std.array.assocArray!(Zip!(Result,
Result)) error instantiating
--
More information about the Digitalmars-d-bugs
mailing list