-
Notifications
You must be signed in to change notification settings - Fork 313
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
Coercion scope bug #282
Coercion scope bug #282
Conversation
…on the superclass
You can also see this by calling instance[:nested].class
=> NestedCoercableHash
[5] pry(#<RSpec::ExampleGroups::HashieExtensionsCoercion::CoerceKey::Nesting>)> instance[:nested].class.key_coercions
=> {:foo=>Symbol, :bar=>Integer, :nested=>NestedCoercableHash, :other=>OtherNestedCoercableHash, :nested_list=>[NestedCoercableHash], :nested_hash=>{String=>NestedCoercableHash}} It would make sense for coercions in |
Yep :( |
I think it's fixed. Double check it for me... I was expecting it to be something trickier. In fact, I'm not sure this is 100% fixed. It perhaps it still has issues with deeply nested coercable structures. Is there a way to kill off the |
There was a bug that was similar to this one, only in reverse, for indifferent_access (see #195). I think the takeaway is that book-keeping for this type of stuff is hard. In this case, the What feels like a hack about the inherited hook to you? It makes a lot of domain sense to me. Without changing the way we do book-keeping -- which I'm not sure how we could, given the modular nature -- I can't think of a better way to express this. |
I found this bug too. My rspec test to show it is at martinstreicher@b0d2f96. |
I submitted a PR for my spec. Perhaps it is another demonstration that the fix works in a form more likely to occur in an app. |
I like #288 as well, I would take both tests, either needs a CHANGELOG, please. |
Sure, I will add one. |
CHANGELOG updated in my branch. |
Merged spec via fd07b80. |
|
## 3.4.2 (6/2/2015) * [#292](hashie/hashie#292): Removed `Mash#id` and `Mash#type` - [@jrochkind](https://github.com/jrochkind). * [#297](hashie/hashie#297): Extracted `Trash`'s behavior into a new `Dash::PropertyTranslation` extension - [@michaelherold](https://github.com/michaelherold). ## 3.4.1 * [#269](hashie/hashie#272): Added Hashie::Extensions::DeepLocate - [@msievers](https://github.com/msievers). * [#270](hashie/hashie#277): Fixed ArgumentError raised when using IndifferentAccess and HashWithIndifferentAccess - [@gardenofwine](https://github.com/gardenofwine). * [#281](hashie/hashie#281): Added #reverse_merge to Mash to override ActiveSupport's version - [@mgold](https://github.com/mgold). * [#282](hashie/hashie#282): Fixed coercions in a subclass accumulating in the superclass - [@maxlinc](https://github.com/maxlinc), [@martinstreicher](https://github.com/martinstreicher).
Found a nasty bug.
The coercions are being stored on the superclass rather than the current class. This means that two classes that share the same superclass can't have conflicting coercions. This PR has I test, I don't have a fix yet.
I can't even mark the test as pending. Just defining
OtherNestedCoercableHash
breaksNestedCoercableHash
even if it's never used. The problem is that it defines the coercion onRootCoercableHash
so the definition from one class leaks into the scope of the other. Since the type was different that breaks other specs.