[Chapel Merge] Implementation of union (in)equality operators

Branch: refs/heads/main
Revision: 9d7e5103a5fa0827318ff78f804e901f7260979f
Author: bradcray
Link: Implementation of union (in)equality operators by bradcray · Pull Request #28699 · chapel-lang/chapel · GitHub
Log Message:
Implementation of union (in)equality operators (#28699)

[reviewed by @DanilaFe]

This implements union equality and inequality as module code, building
on the support for the generic 'union' type that Jade added in #28601
and following the pattern of module-based record comparisons in #28731.
Note that pragma "last resort" was not required here as it was for the
record operators since we don't currently support generic unions
(#28758).

The implementation follows a sketch I put together in discussing

cleaned up based on the review of #28731.

Tests added in this PR:

  • unionEquality.chpl: Tests that == and != work as I'd expect

  • userOverload.chpl: Makes sure that a user-defined overload takes
    precedence over these default ones and doesn't cause an ambiguity.

  • unionEqDiffType.chpl: Tests that == between different unions doesn't
    work as expected, whether they are structurally equivalent or not.

  • unionSelect.chpl: A future that shows that selects on unions that rely
    on == don't work because, today, all union selects are treated as
    active field selections

  • I also added a pair of futures that show that making a second
    argument's type based on the first only inherits the first's type
    constraint, not the actual type of the first argument as we think it
    should (type constraint based on arg with generic formal type too loose · Issue #9310 · chapel-lang/chapel · GitHub). As I
    understand it, this is already fixed in Dyno.

Note that I didn't mark these operators as being unstable or part of a
preview edition since unions are unstable in and of themselves, which I
think is sufficient.

Resolves #14139

Compare: Comparing aa8b425a2e5943e3dde90b0877a376f9af4cc011...09f33282c0b6c13817e400b20935cf086e0fc10f · chapel-lang/chapel · GitHub

Diff:
M modules/internal/ChapelUnion.chpl
A test/types/records/bugs/chainArgType.bad
A test/types/records/bugs/chainArgType.chpl
A test/types/records/bugs/chainArgType.future
A test/types/records/bugs/chainArgType.good
A test/types/records/bugs/chainArgType2.bad
A test/types/records/bugs/chainArgType2.chpl
A test/types/records/bugs/chainArgType2.future
A test/types/records/bugs/chainArgType2.good
A test/types/unions/equality/unionEqDiffType-u3.good
A test/types/unions/equality/unionEqDiffType.chpl
A test/types/unions/equality/unionEqDiffType.compopts
A test/types/unions/equality/unionEqDiffType.good
A test/types/unions/equality/unionEquality.chpl
A test/types/unions/equality/unionEquality.good
A test/types/unions/equality/unionSelect.bad
A test/types/unions/equality/unionSelect.chpl
A test/types/unions/equality/unionSelect.future
A test/types/unions/equality/unionSelect.good
A test/types/unions/equality/userOverride.chpl
A test/types/unions/equality/userOverride.good
https://github.com/chapel-lang/chapel/pull/28699.diff