[Issue 24202] std.range.chain ganerated object has wrong .init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 28 18:19:10 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24202

Ate Eskola <Ajieskola at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Ajieskola at gmail.com

--- Comment #2 from Ate Eskola <Ajieskola at gmail.com> ---
I'm a bit on the fence on whether I agree with this being a regression.
However, I should declare conflict of interest. I was the one who wrote the
optimisation that broke this so potentially I'm just excusing my shortcomings.

The issue here is you're not really depending on what `chain` by itself does.
Instead, you're depending on the initial state of it's type, which is
undocumented and therefore, arguably implementation-defined. In principle you
can expect predictable behaviour from the type only if you initialise it or
assign to it with the `chain` function.

On the other hand, in practice we do depend on stuff like this every now and
then anyway. The `.init` value for `Chain` type could be calculated at compile
time so that it'd agree with the `chain` function call when all the subranges
are also at their `.init` value. I think this is would be an improvement, but
I'm not sure whether it'd qualify as a real regression fix.

--


More information about the Digitalmars-d-bugs mailing list