D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17711 - std.array.byPair should be usable with const AA
Summary: std.array.byPair should be usable with const AA
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2017-08-01 22:53 UTC by hsteoh
Modified: 2018-01-05 13:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hsteoh 2017-08-01 22:53:39 UTC
Code:
------
import std.array;
const(int[string]) aa = [ "abc": 123 ];
auto r = aa.byPair;
------

This code ought to compile, but doesn't, because const(int[string]) does not match the function declaration `auto byPair(K,V)(Value[Key] aa)`.

However, the implementation actually supports iterating over const AA's just fine. We just need to declare the function differently so that it will match a const AA type:

------
auto byPair(AA : V[K], V, K)(AA aa)
------
Comment 1 hsteoh 2017-08-01 23:01:20 UTC
https://github.com/dlang/phobos/pull/5668
Comment 2 github-bugzilla 2017-08-02 08:55:55 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/0c0aed8662dcd3579de4521c98ce0facbfd774fe
Fix issue 17711: std.array.byPair ought to work with const AA's.

https://github.com/dlang/phobos/commit/e4e858bf50e01f7bc9566b6fd56d9e3ff867d1a8
Merge pull request #5668 from quickfur/issue17711

Fix issue 17711: std.array.byPair ought to work with const AA's.
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
Comment 3 github-bugzilla 2017-08-16 13:24:31 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/0c0aed8662dcd3579de4521c98ce0facbfd774fe
Fix issue 17711: std.array.byPair ought to work with const AA's.

https://github.com/dlang/phobos/commit/e4e858bf50e01f7bc9566b6fd56d9e3ff867d1a8
Merge pull request #5668 from quickfur/issue17711
Comment 4 github-bugzilla 2018-01-05 13:30:56 UTC
Commits pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/0c0aed8662dcd3579de4521c98ce0facbfd774fe
Fix issue 17711: std.array.byPair ought to work with const AA's.

https://github.com/dlang/phobos/commit/e4e858bf50e01f7bc9566b6fd56d9e3ff867d1a8
Merge pull request #5668 from quickfur/issue17711