digitalmars.D.bugs - [Issue 6982] New: immutability isn't respected on array assignment
- d-bugmail puremagic.com (31/31) Nov 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (18/18) Nov 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (13/13) Nov 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (19/19) Nov 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (12/12) Nov 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (15/15) Dec 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (26/26) Dec 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (10/10) Mar 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (9/9) Mar 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6982
- d-bugmail puremagic.com (10/10) Mar 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6982
http://d.puremagic.com/issues/show_bug.cgi?id=6982 Summary: immutability isn't respected on array assignment Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: mrmocool gmx.de --- Comment #0 from Trass3r <mrmocool gmx.de> 2011-11-21 08:04:48 PST --- //struct Bla {} alias int Bla; import std.stdio; void main() { immutable(Bla[]) _a; writeln(_a.length); // prints 0 // _a.length = 5; // Error: variable _a cannot modify immutable immutable(Bla)[] a = _a; a.length = 5; // compiles, but: writeln(_a.length); // prints 0 immutable(Bla[string]) _files; immutable(Bla)[string] files = _files; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |timon.gehr gmx.ch Resolution| |INVALID --- Comment #1 from timon.gehr gmx.ch 2011-11-21 08:30:21 PST --- That works as designed. I do not understand what you would expect it to do. immutable(Bla[]) _a; // this is an array that cannot be changed immutable(Bla)[] a; // this is an array whose elements cannot be changed a = _a; // fine. a is now a slice to _a's data a.length = 5; // reallocate storage for a. assert(_a.length == 0); // length of _a does not change as it is a different variable -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 --- Comment #2 from Trass3r <mrmocool gmx.de> 2011-11-21 08:43:41 PST --- Yeah, was a subtle error in reasoning. But what about the assoc. array case? immutable(Bla[string]) _files = ["a":1, "b":2, "c":3]; immutable(Bla)[string] files = _files; // works files["d"] = 5; // Error: files["d"] isn't mutable writeln(_files); writeln(files); gdc rejects the assignment. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 Trass3r <mrmocool gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | --- Comment #3 from Trass3r <mrmocool gmx.de> 2011-11-21 08:51:18 PST --- Yep, it breaks immutability: immutable(Bla[string]) _files = ["a":1, "b":2, "c":3]; immutable(Bla)[string] files = _files; files.remove ("a"); writeln(_files); writeln(files); prints: ["b":2, "c":3] ["b":2, "c":3] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|immutability isn't |immutability isn't |respected on array |respected on associative |assignment |array assignment --- Comment #4 from timon.gehr gmx.ch 2011-11-21 12:06:10 PST --- Ok, I see. I change the title to reflect the actual bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 --- Comment #5 from Kenji Hara <k.hara.pg gmail.com> 2011-12-18 06:30:45 PST --- I think there are at least two issues. void main() { alias int Bla; immutable(Bla[string]) ifiles = ["a":1, "b":2, "c":3]; immutable(Bla)[string] files = ifiles; // (1) ifiles.remove ("a"); // (2) } 1. Implicitly conversion from immutable to mutable AA reference. 2. Call 'remove' from immutable AA reference. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #6 from bearophile_hugs eml.cc 2011-12-18 07:39:16 PST --- A related problem (I think I have already put this in Bugzilla, but I don't remember the issue number): void main() { int[char[]] aa; // line 2 char[] a1 = "hello".dup; aa[a1] = 1; // line 4 } It's stupid for D language to accept the line 2 and then refuse line 4 with: test.d(4): Error: associative arrays can only be assigned values with immutable keys, not char[] Line 2 too needs to become an error. So a better error message is something like: test.d(2): Error: built-in associative arrays accept only immutable keys, not char[] Or alternatively: test.d(2): Error: built-in associative arrays can be defined only with immutable keys, not char[] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6982 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #7 from Kenji Hara <k.hara.pg gmail.com> 2012-03-11 06:35:43 PDT --- https://github.com/D-Programming-Language/dmd/pull/799 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6982 --- Comment #8 from github-bugzilla puremagic.com 2012-03-11 18:08:03 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/229a37a1ae0766a54cbe64fc3995847aa17f17fb Merge pull request #799 from 9rnsr/fix6982 Issue 6982 - immutability isn't respected on associative array assignment -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6982 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 11 2012