Bug 21022 – std.range.only does not work with const

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-07T08:35:21Z
Last change time
2021-10-19T18:06:06Z
Keywords
industry, pull
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2020-07-07T08:35:21Z
----- module test; import std.range; struct S { S[] s; } void main () { const(S) x; const(S)[] arr; auto r1 = arr.chain(x.only); // fail auto r2 = x.only.chain(arr); // also fail } ----- /Library/D/dmd/src/phobos/std/range/package.d(9805,23): Error: cannot implicitly convert expression `value` of type `const(S)` to `S` /Library/D/dmd/src/phobos/std/range/package.d(9890,57): Error: template instance `std.range.OnlyResult!(const(S), 1LU).OnlyResult.__ctor!()` error `Only` internally stores an Unqual instance of the type. I don't know why, but this will obviously fail to work..
Comment #1 by dlang-bot — 2021-10-13T17:31:03Z
@dukc created dlang/phobos pull request #8271 "Fix issue 21022 - only should work with qualifiers" fixing this issue: - Fix issue 21022 - only should work with qualifiers https://github.com/dlang/phobos/pull/8271
Comment #2 by dlang-bot — 2021-10-19T18:06:06Z
dlang/phobos pull request #8271 "Fix issue 21022 - only should work with qualifiers" was merged into master: - 769299f70b03a05a817843b331af9f42f919a486 by Ate Eskola: Fix issue 21022 - only should work with qualifiers https://github.com/dlang/phobos/pull/8271