---
import std.bitmanip;
void main(string[] args)
{
BitArray a;
a.len = 1;
a[0] = 1;
}
---
crashes because len shouldnt be only set using the length() setter.
Comment #1 by github-bugzilla — 2015-11-19T15:51:02Z
If you land here because some code is broken in phobos 2.070 note that you can fix by using the copy constructor that takes a size_t & void* (len,ptr) as parameter.
Comment #4 by schveiguy — 2016-01-26T03:58:29Z
Has been "reverted", albeit with deprecations. Reopening so it doesn't get forgotten -- yes, you can once again mess up BitArray by writing directly to len and ptr.
Reference: https://github.com/D-Programming-Language/phobos/pull/3950
Comment #5 by andrei — 2016-12-23T21:20:06Z
Current compilation result:
/d498/f670.d(6): Error: no property 'len' for type 'BitArray', did you mean '_len
The following commit related to this issue
https://github.com/dlang/phobos/commit/74fbb79087c46ebde38ac3648b6a46b76f2a0a9e
has apparently overreached when setting bitsPerSizeT as private state.
The intended fix is successful in hiding .len and .ptr, but there is no explicit rationale (in this thread and in the commit message) for also encapsulating .bitsPerSizeT.
Namely, the question is: why has BitArray.bitsPerSizeT been made a private member? It's an enum. It can't be accidentally nor intentionally rewritten.
I've ran into "variable std.bitmanip.BitArray.bitsPerSizeT is not accessible from module" errors because my module imports from an (albeit old) library which implements certain bit setting algorithm that relies on BitArray.bitsPerSizeT being publicly accessible.
(If you need to know, the library in question is artemisd:)
https://github.com/elvisxzhou/artemisd
After examining the problem, the commit and the issue that produced the problem, I believe that the mentioned commit introduces an unintended regression, and that it deserves to be reviewed.