[Chapel Merge] Throw if a byte-based string slice is misaligned

Branch: refs/heads/main
Revision: 8a569cb
Author: e-kayrakli
Link: Throw if a byte-based string slice is misaligned by e-kayrakli · Pull Request #19681 · chapel-lang/chapel · GitHub
Log Message:

Merge pull request #19681 from e-kayrakli/string-misaligned-slice

Throw if a byte-based string slice is misaligned

This PR makes byteIndex-based string slicing throw if it slices codepoints.

Resolves https://github.com/Cray/chapel-private/issues/941.

Motivated by https://github.com/Cray/chapel-private/issues/937#issuecomment-622006746
Motivated by Rework the helper for string/bytes slicing by e-kayrakli · Pull Request #15615 · chapel-lang/chapel · GitHub

This is achieved by making the shared slicing helper getView to check for
codepoint boundary alignment. If there's a misalignment it will throw a
CodepointSplittingError. The rest of the code changes are essentially
throwing in bunch of try!s.

[Reviewed by @arezaii]

Test:

  • [x] standard

    Modified Files:
    A test/types/string/ilseqByteSlice.chpl
    A test/types/string/ilseqByteSlice.good
    A test/types/string/ilseqByteSlice2.chpl
    A test/types/string/ilseqByteSlice2.good
    M modules/internal/Bytes.chpl
    M modules/internal/BytesStringCommon.chpl
    M modules/internal/String.chpl
    M modules/standard/Errors.chpl
    M modules/standard/Path.chpl
    M modules/standard/Regex.chpl
    M test/types/string/StringImpl/memLeaks/substring_byte.chpl

    Compare: Comparing c5bbac6138ea...8a569cb358f8 · chapel-lang/chapel · GitHub