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/2856https://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.