Bug 14626 – [REG2.066] byValue doesn't work with inout AA

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-05-28T08:33:00Z
Last change time
2017-07-19T17:41:51Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2015-05-28T08:33:25Z
///////////// test.d ///////////// struct S { string[string] aa; inout(string) m() inout { return aa.byValue().front; } } ////////////////////////////////// C:\...\druntime\object.d(1906): Error: inout on return means inout must be on a parameter as well for @property ref Value() test.d(7): Error: template instance object.byValue!(inout(string[string]), inout(string), string) error instantiating Introduced in: https://github.com/D-Programming-Language/dmd/pull/2856 https://github.com/D-Programming-Language/druntime/pull/668
Comment #1 by schveiguy — 2015-05-28T13:42:26Z
That it worked before I think is a bug (the compiler did a lot of hand-waving with AA's to avoid sticky issues). We really really need a way to specify something returns or uses inout that isn't a *new* inout scope. Only then, can we get this to work.
Comment #2 by code — 2015-07-01T09:53:00Z
But byValue should work with const AAs and inout is convertible to const, so it seems the template signature of byValue is incorrect.
Comment #3 by code — 2015-07-01T09:59:09Z
Looks like the classical, mutable iterator over const/immutable container issue complicated by inout. Not sure if we can solve it with the current language features.
Comment #4 by k.hara.pg — 2015-07-16T14:18:38Z
(In reply to Steven Schveighoffer from comment #1) > That it worked before I think is a bug (the compiler did a lot of > hand-waving with AA's to avoid sticky issues). Yes, there was a compiler hack for the inout key/value types. https://github.com/D-Programming-Language/dmd/blob/v2.065.0/src/mtype.c#L4897 (In reply to Martin Nowak from comment #3) > Looks like the classical, mutable iterator over const/immutable container > issue complicated by inout. > Not sure if we can solve it with the current language features. It would be a new DIP to extend inout feature.
Comment #5 by k.hara.pg — 2015-07-16T14:19:17Z
Emulate the 2.065 and earlier behavior. https://github.com/D-Programming-Language/druntime/pull/1324
Comment #6 by github-bugzilla — 2015-07-17T16:57:17Z
Commits pushed to stable at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/6d57c68df1f72e9416548ad450e56a16bb1fdb90 fix Issue 14626 - byValue doesn't work with inout AA Until 2.065, compiler had substituted all `inout` qualifiers in the `Key` and `Value` types to `const`, then those had passed to the template struct `AssociativeArray`. https://github.com/D-Programming-Language/dmd/blob/v2.065.0/src/mtype.c#L4897 This change emulates that. https://github.com/D-Programming-Language/druntime/commit/ad900eb3cc38397c4fa3a0a805793f002d03abc7 Merge pull request #1326 from 9rnsr/fix14626 [REG2.066] Issue 14626 - byValue doesn't work with inout AA
Comment #7 by github-bugzilla — 2015-07-24T03:48:10Z
Comment #8 by github-bugzilla — 2017-07-19T17:41:51Z