Skip to content

cgen: support inc cond for c style for loop with alias types - #21708

Merged
spytheman merged 4 commits into
vlang:masterfrom
Delta456:alias_for_c_loop_assign_inc
Jun 22, 2024
Merged

spytheman merged 4 commits into
vlang:masterfrom
Delta456:alias_for_c_loop_assign_inc

Conversation

@Delta456

Copy link
Copy Markdown
Member

Fixes #21707

@Delta456
Delta456 marked this pull request as ready for review June 20, 2024 19:16
Comment thread vlib/v/slow_tests/inout/alias_for_c_loop_assign_op.vv
Comment thread vlib/v/gen/c/assign.v
Comment on lines -523 to +525
g.write(';')
if !g.inside_for_c_stmt {
g.write(';')
}

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.

That is short, but does not seem the right place for the fix.
Why does the non aliased case work, without such check?

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.

It is because the assignment operator overloading here assumes to be a statement ending with the ; but in a for c loop it is not the case. I also can't find a better place to make it work because it returns after code generation.

I tried removing the return and adding the g.write(';') but the compiler failed.

@spytheman
spytheman merged commit 2bb815f into vlang:master Jun 22, 2024
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.

c-style for loop with type alias provokes build error

2 participants