Skip to content

ast: get correct generics for generics struct fn with generic param#26251

Merged
spytheman merged 1 commit into
vlang:masterfrom
dy-tea:generic-fn
Jan 3, 2026
Merged

ast: get correct generics for generics struct fn with generic param#26251
spytheman merged 1 commit into
vlang:masterfrom
dy-tea:generic-fn

Conversation

@dy-tea

@dy-tea dy-tea commented Jan 2, 2026

Copy link
Copy Markdown
Member

Fixes #26191.

Comment thread vlib/v/ast/table.v
converted_args << converted_type_str
changed = true
if converted_type.has_flag(.generic) {
has_generic = true

@spytheman spytheman Jan 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you have a continue here, you can save on the else {} branches below

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another alternative is to invert the conditions, and do early if inverted_cond { converted_args << arg continue }, which can save on the depth of the nesting inside the loop

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.
Thank you @dy-tea 🙇🏻 .

@spytheman

Copy link
Copy Markdown
Contributor

The CI failure is unrelated.

@spytheman spytheman merged commit 604417e into vlang:master Jan 3, 2026
81 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generic method of generic struct

2 participants