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

Unable to unmarshal empty leafs within union types #582

Open
wenovus opened this issue Sep 7, 2021 · 2 comments
Open

Unable to unmarshal empty leafs within union types #582

wenovus opened this issue Sep 7, 2021 · 2 comments
Labels

Comments

@wenovus
Copy link
Collaborator

wenovus commented Sep 7, 2021

#292 would fix the case for straight-up empty-type leaves. But it doesn't address unmarshalling a union leaf that contains an empty type.

  1. Is this unlikely to occur in practice?
  2. I'd prefer to only solve this for the simple union case to avoid unnecessary work.
  3. When solving this for the simple union case, an easy way would be to generate the following for the To_XXX methods, would this be acceptable, since it prevents having both YANGEmpty and bool within the same union type?:
switch v := i.(type) {
case bool:                                                                                                                   
   return YANGEmpty(v), nil
}

in addition to the obvious

func (YANGEmpty) Documentation_for_Platform_Component_Power_Union() {}

You could argue that the former is not necessary, but it really helps simplify the unmarshalling code, as otherwise it would require lots of generated code analogous to ΛEnumTypeMap in order to create the YANGEmpty type from the correct package when unmarshalling from either JSON or TypedValue.

@wenovus
Copy link
Collaborator Author

wenovus commented Sep 7, 2021

My personal take is that this doesn't need to be part of the v1 milestone since it doesn't introduce any backwards incompatibility issues, and is likely a corner case not usually encountered.

@wenovus
Copy link
Collaborator Author

wenovus commented Sep 10, 2021

This issue is only relevant when unmarshalling JSON. When unmarshalling a TypedValue, YANGEmpty and bool are indistinguishable from one another in their encoding.

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

No branches or pull requests

1 participant