← Back to index
|
Original Bugzilla link
Bug 21087 – refRange() does not work with ranges which have internal const fields
Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-29T05:10:59Z
Last change time
2024-12-01T16:37:23Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: phobos#9804 →
Comments
Comment #0
by andrej.mitrovich — 2020-07-29T05:10:59Z
``` import std.range; public static auto byRange () { static struct Range { size_t lbound = 0; const size_t hbound = 100; size_t length () const { return 0; } bool empty () const { return false; } int front () const { return 0; } void popFront () { } } return Range(0); } void main () { auto keys = byRange(); auto r = refRange(&keys); } ``` $ dmd test.d > /Library/D/dmd/src/phobos/std/range/package.d(11504,13): Error: cannot modify struct instance `*this._range` of type `Range` because it contains `const` or `immutable` members > /Library/D/dmd/src/phobos/std/range/package.d(12215,16): Error: template instance `std.range.RefRange!(Range)` error instantiating test.d(22,22): instantiated from here: `refRange!(Range)` As a workaround `hbound` can be declared an enum here.
Comment #1
by robert.schadek — 2024-12-01T16:37:23Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/phobos/issues/9804
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB