fix: constraint interfaces generation#1125
Merged
LandonTClipp merged 3 commits intovektra:v3from Dec 16, 2025
Merged
Conversation
internal/parse.go
Outdated
Comment on lines
+206
to
+215
| // Example: | ||
| // type I interface { | ||
| // constraints.Float | ||
| // } | ||
| if sel, ok := item.Type.(*ast.SelectorExpr); ok { | ||
| if id, ok := sel.X.(*ast.Ident); ok && id.Name == "constraints" { | ||
| return true | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
I think this is fine but it's easily tricked. You can create an alias to a constraints.Float and this check would not catch it. You would need an additional check for alias types, then resolve the alias, then perform the same checks you added here.
That doesn't have to be included in this PR, but it's something to think about. You mention this in the description so I'm not telling you something new.
Contributor
Author
There was a problem hiding this comment.
Hi. Thanks for the tip. Thanks to this, i also found a way to check aliases for constraint interfaces
Member
|
I haven't forgotten this, I will get to it soon! |
LandonTClipp
approved these changes
Dec 16, 2025
Member
|
Merged, thanks again 🫡 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
I added a check to the parser for whether the interface is a constraint. Mocks will not be generated using such interfaces.
Examples of interfaces that will be skipped:
Type of change
Version of Go used when building/testing:
How Has This Been Tested?
I wrote a test in fixtures with several constraint interfaces. If no mocks are generated for them, the test will be completed successfully.
Fixture path:
internal/fixtures/constraint_ifacesChecklist