Open mattsep opened 2 years ago
Did this get fixed? I cannot reproduce this on the main branch
Updated the example
Is this now fixed?
Not yet - this issue arises due to how exclusive ranges are converted to inclusive ranges at parse time. I think inclusive and exclusive ranges need to be parsed separately, and only converted to one or the other at a later time, once we have full knowledge of the bounds and step size.
There is a bug in the parsing of exclusive ranges that is showcased by this example:
This happens because the exclusive range
1.0 ... 1.2 : 0.15
is converted to1.0 .. 1.05 : 0.15
by subtracting the step from the end, which is not the right thing to do in this situation. Since this happens at parse time, it's not possible to revert this calculation in therange_count
function.If we were to instead convert all inclusive ranges to exclusive ranges by adding the step to the end, we would find that
1.0 .. 1.2 : 0.15
would be converted to1.0 ... 1.35 : 0.15
which would print[ 1, 1.15, 1.3 ]
and this is also not correct.What we likely need is to explicitly flag whether a given range is inclusive or exclusive range at construction so that we can compute the correct number of elements in the
range_count
function, at which point we can convert both ranges to one or the other.