-
Notifications
You must be signed in to change notification settings - Fork 607
Type-safe return values #622
Comments
The reason this suggestion was closed in the path is it sounded like it would be a breaking change. Looking at this prop that is also true. I think if we were going to do something like this in the future we would want to do it in a way that is backwards compatible. Do you have a suggested API that is not a breaking change? |
The code will break with this change it already broken at runtime (always panic). This change only make then break early to compile time. non-breaking-change Suggestions:
Personally I prefer first one. |
@codyoss any thoughts on these suggestions? |
Another mock generator support typed-return https://github.com/vektra/mockery And it's kinda funny because it doesn't support type safe matcher... |
I don't disagree that overall type-safe returns would be a good idea, but there are potentially people exploiting the current state that may be broken. Let me think about this some more and see if this issue gets more traction. The flag suggestion seems like an okay idea though. |
This would also be very interesting for me 👍 . Not having typed returns makes test maintenance harder. |
Requested feature
This issue proposal generating a typed
.Return(
for*gomock.Call
.it's a re-open for closed issue #427 .
Why the feature is needed
currently
.Return(
has a sigurate offunc (rets ...interface{})
can accept any return value in compile time.But wrong return values' type result in always failing at runtime, which can be avoided at compile time.
Proposed solution
User Code
Generated mocks
User Test Code
The text was updated successfully, but these errors were encountered: