Replace with_merged_former_errors by validate_and_merge_errors #17882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main problem with the previous method was that it only worked if the contract being validated inside the block was sharing the same
errors
object as the contract calling it. The old implementation was incapable of incorporating errors from a contract that had its ownerrors
object. Sharing of theerrors
object is pretty common among our contracts, because most of them just delegate theerrors
method (among others) to the model being validated.In my opinion it's a code smell that our contracts use the
errors
of the model they are validating as the place to store their validation result, however I didn't dare touching this yet, because changing that would certainly be a huge change (e.g. because it means that validating the contract will change the model being inspected). I can also imagine that some places rely on it for historic reasons (because using "classic" validations also puts the errors on the model). However, I think that no two contracts should RELY on using the SAME errors object, just because the way we implemented them happens to cause them to share the same object.What are you trying to accomplish?
This PR was coupled out from #17838 to be able to discuss and test this change separately. In #17838 I want to add a
ComposedContract
which is essentially a way of combining multiple contracts into one.That class is not reusing the errors object of the model under test, because that would introduce an unintended coupling between the contracts that I'd need to work around.