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 T::Struct prop names #78

Open
jscheid opened this issue Jan 12, 2023 · 0 comments
Open

Support T::Struct prop names #78

jscheid opened this issue Jan 12, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jscheid
Copy link

jscheid commented Jan 12, 2023

Describe the bug:

Doesn't currently seem to support T::Struct prop names.

Steps to reproduce:

[1] pry(main)> class X < T::Struct; const :foo, Integer, name: 'bar'; end
=> T::Private::Types::Void::VOID
[2] pry(main)> X.from_hash({ 'bar' => 123 })
=> <X foo=123>
[3] pry(main)> X.from_hash({ 'foo' => 123 })
RuntimeError: Error in X#__t_props_generated_deserialize: Tried to deserialize a required prop from a nil value. [SNIP]
[4] pry(main)> TypeCoerce[X].new.from({ 'bar' => 123 })
ArgumentError: Missing required prop `foo` for class `X` [SNIP]
[5] pry(main)> TypeCoerce[X].new.from({ 'foo' => 123 })
=> <X foo=123>
[6] pry(main)> 

Expected behavior:

TypeCoerce[Struct].new.from should probably behave similar to Struct.from_hash.

Versions:

  • Sorbet-Coerce: 0.7.0
@jscheid jscheid added the bug Something isn't working label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant