Bug 11761 – aa.byKey and aa.byValue are not forward ranges
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-17T21:49:00Z
Last change time
2014-08-15T10:34:35Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2013-12-17T21:49:23Z
Currently, associative arrays' byKey and byValue methods do not return forward ranges (although this was the intention). The isForwardRange check fails.
The cause can be reduced to the following code:
struct R
{
R save() { return this; }
}
void main()
{
R r1 = void;
static assert (is(typeof(r1.save) == typeof(r1)));
}
The compiler complains:
test.d(9): Error: static assert (is(R() == R)) is false
Note the parens in "R() == R".
The problem goes away, if either r1.save is replaced with r1.save(), or the save method declaration is annotated with @property (despite the -property switch not being used).
(In reply to Vladimir Panteleev from comment #0)
> Currently, associative arrays' byKey and byValue methods do not return
> forward ranges (although this was the intention). The isForwardRange check
> fails.
(In reply to hsteoh from comment #2)
> https://github.com/D-Programming-Language/druntime/pull/925
Change the "Component" field because it's druntime issue.
Comment #4 by github-bugzilla — 2014-08-15T08:52:52Z
(In reply to Vladimir Panteleev from comment #0)
> The cause can be reduced to the following code:
>
> struct R
> {
> R save() { return this; }
> }
>
> void main()
> {
> R r1 = void;
> static assert (is(typeof(r1.save) == typeof(r1)));
> }
>
> The compiler complains:
>
> test.d(9): Error: static assert (is(R() == R)) is false
>
> Note the parens in "R() == R".
>
> The problem goes away, if either r1.save is replaced with r1.save(), or the
> save method declaration is annotated with @property (despite the -property
> switch not being used).
The compiler behavior issue is now filed in bug 13293.
Comment #6 by dlang-bugzilla — 2014-08-15T10:34:35Z