We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
try
Hi there, I found a couple of bugs working with structs and types in try method
struct = Dry::Struct(id: Types::Integer) type = Types::Array.of(struct) # => #<Dry::Types[Constrained<Array<#<Class:0x0000000114d33398>> rule=[type?(Array)]>]> type.try([{}]) # ArgumentError: error must be a CoercionError # from /Users/pyromaniac/.rvm/gems/ruby-3.1.4@bookingsync/gems/dry-types-1.7.1/lib/dry/types/nominal.rb:122:in `failure' # type.try([{id: 1}]) # => #<Dry::Types::Result::Success input=[#<#<Class:0x0000000114d33398> id=1>]> type.try([struct.new(id: 1)]) # => #<Dry::Types::Result::Success input=[#<#<Class:0x0000000114d33398> id=1>]> struct2 = Dry::Struct(id2: Types::Integer) # => #<Class:0x0000000114f90c58> type = Types::Array.of(struct | struct2) # Btw, the inspection is also weird here # => #<Dry::Types::Constrained:0x163b4> type.try([{}]) # ArgumentError: error must be a CoercionError # from /Users/pyromaniac/.rvm/gems/ruby-3.1.4@bookingsync/gems/dry-types-1.7.1/lib/dry/types/nominal.rb:122:in `failure' type.try([{id: 1}]) # => #<Dry::Types::Result::Success input=[#<#<Class:0x0000000114d33398> id=1>]> type.try([struct.new(id: 1)]) # NoMethodError: undefined method `input' for #<#<Class:0x0000000114d33398> id=1> # # output << r.input unless Undefined.equal?(r.input) # ^^^^^^ # from .rvm/gems/ruby-3.1.4/gems/dry-types-1.7.1/lib/dry/types/array/member.rb:79:in `block in try'
No errors are expected for those 2 cases.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Hi there, I found a couple of bugs working with structs and types in
try
methodTo Reproduce
Expected behavior
No errors are expected for those 2 cases.
My environment
The text was updated successfully, but these errors were encountered: