Skip to content

cgen: fix codegen for indexexpr on for loop with branchstmt - #24289

Merged
spytheman merged 1 commit into
vlang:masterfrom
felipensp:fix_index_on_loop
Apr 22, 2025
Merged

spytheman merged 1 commit into
vlang:masterfrom
felipensp:fix_index_on_loop

Conversation

@felipensp

Copy link
Copy Markdown
Member

Fix #22760

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22667

Comment thread vlib/v/gen/c/cgen.v
Comment on lines +2203 to 2207
if stmt is ast.ExprStmt && (g.inside_if_option || g.inside_if_result
|| g.inside_match_option || g.inside_match_result
|| (stmt.expr is ast.IndexExpr && stmt.expr.or_expr.kind != .absent)) {
g.writeln(';')
}

@spytheman spytheman Apr 22, 2025 •

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 seems to be getting very complex; I wonder if it would not be simpler, to just always append the ; (even at the cost of uglier/redundant generated C)

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

Good work.

@spytheman
spytheman merged commit b76b1ee into vlang:master Apr 22, 2025
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.

the error expression evaluated but not used is not reported for arr[i] or { break } inside a for loop

2 participants