Skip to content

cgen: fix comptime match assign in generic fn, T.name string intp#26597

Merged
spytheman merged 1 commit into
vlang:masterfrom
dy-tea:comptime-match
Feb 16, 2026
Merged

cgen: fix comptime match assign in generic fn, T.name string intp#26597
spytheman merged 1 commit into
vlang:masterfrom
dy-tea:comptime-match

Conversation

@dy-tea

@dy-tea dy-tea commented Feb 12, 2026

Copy link
Copy Markdown
Member

Fixes #26053.

Hopefully more of this logic can be moved out of cgen in v2. Checks already passed on my branch.

Comment thread vlib/v/gen/c/fn.v Outdated
Comment thread vlib/v/gen/c/fn.v Outdated
Comment thread vlib/v/gen/c/fn.v Outdated
Comment thread vlib/v/gen/c/str_intp.v Outdated
Comment thread vlib/v/gen/c/str_intp.v
node_.expr_types[i] = field_typ
} else if field_typ != ast.void_type {
if i >= node_.expr_types.len {
node_.expr_types << field_typ

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.

same - restore this to just node_.expr_types[i] = field_typ; there is no need for the if i >= node_.expr_types.len { check, and it can make other problems harder, since it does something more suited for the checker

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not having this guard is giving index out of range for me :/

@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.

Thank you @dy-tea 🙇🏻 .

I am still not convinced that line 379 with the <<, is needed, because I did a local run where it was replaced by a panic, and v test-all passed. I'll experiment more, and make a separate PR for it, to make it run the full CI, without blocking this further.

@spytheman spytheman merged commit 64bade1 into vlang:master Feb 16, 2026
90 checks passed
@dy-tea dy-tea deleted the comptime-match branch February 16, 2026 17:44
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.

$match assignment will crash compiler

3 participants