Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unions to be read when there is no matching case or default for the specified discriminator value #206

Conversation

snosenzo
Copy link
Collaborator

@snosenzo snosenzo commented Aug 2, 2024

Changelog

  • Allow unions to be read when there is no matching case or default for the specified discriminator value

Docs

Description

See Section 7.4.1.4.4.4.2 of https://www.omg.org/spec/IDL/4.2/PDF:

It is not required that all possible values of the union discriminator be listed in the <switch_body>. The value of a
union is the value of the discriminator together with one of the following:

  1. If the discriminator value was explicitly listed in a case statement, the value of the element associated with
    that case statement.
  2. If a default case label was specified, the value of the element associated with the default case label.
  3. No additional value.

Previously we were erroring if there was not a case corresponding with the given discriminator value. Now we will return the default if it exists, or an object containing only the discriminator value if there is no default.

BeforeAfter

Copy link

linear bot commented Aug 2, 2024

@snosenzo snosenzo marked this pull request as ready for review August 2, 2024 14:53
@snosenzo snosenzo requested review from achim-k and jtbandes and removed request for achim-k August 2, 2024 14:55
@snosenzo snosenzo merged commit baf4ac6 into main Aug 2, 2024
1 check passed
@snosenzo snosenzo deleted the sam/fg-8310-omgidl-support-for-union-discriminators-without-a-case-type branch August 2, 2024 16:42
snosenzo added a commit that referenced this pull request Aug 5, 2024
### Changelog
<!-- Write a one-sentence summary of the user-impacting change (API,
UI/UX, performance, etc) that could appear in a changelog. Write "None"
if there is no user-facing change -->
- allow discriminators without cases in union messages
#206

### Docs

<!-- Link to a Docs PR, tracking ticket in Linear, OR write "None" if no
documentation changes are needed. -->

### Description

<!-- Describe the problem, what has changed, and motivation behind those
changes. Pretend you are advocating for this change and the reader is
skeptical. -->

<!-- In addition to unit tests, describe any manual testing you did to
validate this change. -->

<table><tr><th>Before</th><th>After</th></tr><tr><td>

<!--before content goes here-->

</td><td>

<!--after content goes here-->

</td></tr></table>

<!-- If necessary, link relevant Linear or Github issues. Use `Fixes:
foxglove/repo#1234` to auto-close the Github issue or Fixes: FG-### for
Linear isses. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants