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

Support defining Type Unions in Hash key or value signatures #150

Open
postmodern opened this issue Aug 21, 2022 · 0 comments
Open

Support defining Type Unions in Hash key or value signatures #150

postmodern opened this issue Aug 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@postmodern
Copy link

Is your feature request related to a problem? Please describe.

I am trying to use sord-4.0.0 to parse a very thoroughly YARD documented library of mine, but noticed that it does not recognize Type Unions within the key or value part of a Hash{K => V} signature.

Describe the solution you'd like

sord should be able to parse the following Hash{...} type signatures:

  • Hash{KeyType1,KeyType2 => ValueType}
  • Hash{KeyType => ValueType1,ValueType2}

Describe alternatives you've considered

The obvious workaround is to change the YARD Hash{...} type signature to Hash{KeyType1 => Value}, Hash{KeyType2 => Value}, however this implies that all of the Hash'es keys are either of KeyType or of KeyType2, but never a mixture of the two key types. I could change the Hash{...} signature to Hash{Object => ValueType} but that makes the Hash type signature less descriptive. In my library KeyType1 and KeyType2 do not have a common base class, so that is also not an option.

Additional context

real world code

@postmodern postmodern added the enhancement New feature or request label Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant