Skip to content

cgen: fix defer stmts with if exprs and or blocks that return a value#25651

Merged
medvednikov merged 2 commits into
vlang:masterfrom
StunxFS:fix-defer-with-or-else-and-if-expr
Nov 4, 2025
Merged

cgen: fix defer stmts with if exprs and or blocks that return a value#25651
medvednikov merged 2 commits into
vlang:masterfrom
StunxFS:fix-defer-with-or-else-and-if-expr

Conversation

@StunxFS

@StunxFS StunxFS commented Nov 3, 2025

Copy link
Copy Markdown
Contributor
  • Fixed the generation of defer stmts with or blocks that return some value (x() or { return 123 }).
  • Fixed the generation of defer within if expressions with a condition that requires a temporary variable (the defer was generated after the goto).

@spytheman

Copy link
Copy Markdown
Contributor

Please add test cases too.

@medvednikov medvednikov merged commit db8fb16 into vlang:master Nov 4, 2025
84 checks passed
@StunxFS StunxFS deleted the fix-defer-with-or-else-and-if-expr branch November 4, 2025 09:03
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.

3 participants