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).
Comment #1 by schuetzm — 2014-08-14T11:29:32Z
See also here, someone else got bitten by this problem too: http://forum.dlang.org/post/[email protected]
Comment #2 by hsteoh — 2014-08-14T14:39:16Z
Comment #3 by k.hara.pg — 2014-08-15T08:46:52Z
(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
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/38eee4cdf371ca9ab49962d2dfadbfb5785d7bcb Merge pull request #925 from quickfur/issue11761 Fix 11761: aa.byKey and aa.byValue are not forward ranges.
Comment #5 by k.hara.pg — 2014-08-15T09:46:01Z
(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
Thanks. Link: issue 13293