[Chapel Merge] Add support for open-interval enum ranges

Branch: refs/heads/master
Revision: f8c0ab9
Author: bradcray
Log Message:

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
for param 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
chpl__orderToEnum routine).

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)

    Modified Files:
    A test/types/range/open/openBoolRange.chpl
    A test/types/range/open/openBoolRange.good
    A test/types/range/open/openEnumRange.chpl
    A test/types/range/open/openEnumRange.good
    A test/types/range/open/paramEnumRange.bad
    A test/types/range/open/paramEnumRange.chpl
    A test/types/range/open/paramEnumRange.future
    A test/types/range/open/paramEnumRange.good
    M compiler/AST/build.cpp
    M modules/internal/ChapelRange.chpl

    Compare: Comparing 4ba5332b44ba...f8c0ab9a87f3 · chapel-lang/chapel · GitHub