Add documentation for language-supplied == and != on unions#28957
Open
bradcray wants to merge 1 commit into
Open
Add documentation for language-supplied == and != on unions#28957bradcray wants to merge 1 commit into
bradcray wants to merge 1 commit into
Conversation
While here, I reordered and changed the headings of a few sections in this chapter to match the records chapter, which I believe has received more attention in recent years. --- Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
DanilaFe
approved these changes
Jun 10, 2026
| types, a compiler error is generated. | ||
|
|
||
| These default comparisons consider two union values to be equal if (a) | ||
| both union have the same active field and (b) those fields are |
Contributor
There was a problem hiding this comment.
bit of a nit, since it's clear what you mean, but "those fieldS" is mismatched with "same active field". Consider: "the respective values of this active field are..."
| union-type: | ||
| identifier | ||
|
|
||
| The union type is specified by the name of the union type. This |
Contributor
There was a problem hiding this comment.
I think it would help me to know that union-type is part of the type expression grammar. Because "union type is specified" is rough, and to me seems a little too close to "defined". I think perhaps we can adjust the opening paragraph of this section to say "The syntax of a union type expression is summarized as follows"?
Member
Author
There was a problem hiding this comment.
This is pre-existing (it just got moved), but I agree with the notion of improving it while I'm here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a description to the language spec of the Chapel-supplied
==and!=operators on unions, as added in #14139 (apparently it didn't occur to me or my reviewer to add them then).While here, I reordered and changed the level of a few sections in this chapter to match the records chapter, which I believe has received more attention in recent years. Specifically, I moved the bit about declaring union types ahead of the section about referring to union types (since one must exist before you can name it, and naming it is strictly less interesting), and I moved assignment and these newly added comparisons into a "Common Operations" section to match records.