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

Enums roundtrip unknown variants #139

Merged
merged 7 commits into from
Oct 5, 2020
Merged

Enums roundtrip unknown variants #139

merged 7 commits into from
Oct 5, 2020

Conversation

bmoylan
Copy link
Contributor

@bmoylan bmoylan commented Sep 15, 2020

Before this PR

Unknown enum variants were all assigned the UNKNOWN value, which is not in line with the conjure spec that specifies they should be stored and round-trippable. Partially addresses #24 (unions require more thought).

After this PR

==COMMIT_MSG==
Enums now preserve unknown variant values. The UNKNOWN value has been removed.
==COMMIT_MSG==

Possible downsides?

This might be a breaking change, especially if people are assuming the generated values are exhaustive (e.g. using switch statements without default cases)


This change is Reviewable

@bmoylan bmoylan requested a review from tabboud September 15, 2020 05:17
@changelog-app
Copy link

changelog-app bot commented Sep 15, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Enums now preserve unknown variant values. The UNKNOWN value has been removed.

Check the box to generate changelog(s)

  • Generate changelog entry

conjure/enum.go Outdated Show resolved Hide resolved
Copy link
Contributor

@asanderson15 asanderson15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is broken. Options are to change the test code not to throw the warning or just bump verifier to 0.16.6, which has the new correct enum test cases.

),
Body: []astgen.ASTStmt{
statement.NewReturn(
expression.NewCallFunction("werror", "Convert",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value in adding in the additional werror.Convert given the NewInvalidArgument will return a proper error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adam asked the same question on Slack. This might be exposing a deficiency with how we implemented the conjure error, but because it's not a werror it doesn't have a stacktrace. I added the werror.Convert as low as possible to preserve the stack frame(s) between here and the next werror.Wrap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants