Merge pull request #17460 from bradcray/open-enum-range
Add support for open-interval enum ranges
[reviewed by @vasslitvinov ]
This PR adds support for open-interval ranges (
..<) over enum values.
This didn't work previously because the implementation subtracted 1
from the high bound and enums don't (currently) support +/- with
integers to advance/rewind along the enumeration (issue #9784).
Here, I'm changing the implementation to move the logic that bumps the
bounds into the ChapelRange module, and then using conversions between
the idx and int types are used to accomplish the same effect.
In order to make this work while continuing to support param ranges of
integers and bools, I had to make both param and non-param versions
of the routines. Doing this revealed that our chpl__intToIndex() routine
int values didn't actually return a
param value... (weird).
It also revealed that we didn't have a param version of chpl__idxtoInt()
for enums, which was easy to add (we also don't have a chpl__intToIndex()
for param enums, but that will require the compiler to generate a param
Added new tests:
openBoolRange: locks in that open interval ranges work for bools
openEnumRange: locks in that they work for enums
paramEnumRange: a future for param loops over open interval ranges
(which will more generally require support for param loops over enum ranges)