digitalmars.D.bugs - [Issue 13909] New: A problem with immutable zip + assocArray
- via Digitalmars-d-bugs (32/32) Dec 29 2014 https://issues.dlang.org/show_bug.cgi?id=13909
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 puremagic.com Reporter: bearophile_hugs 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 --
Dec 29 2014