Skip to content

cgen: fix codegen for nested if on return #23729

Merged
spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_nested_if_option
Feb 15, 2025
Merged

cgen: fix codegen for nested if on return #23729
spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_nested_if_option

Conversation

@felipensp

Copy link
Copy Markdown
Member

Fix #23723

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22147

}

fn test_main() {
c := chan Message{}

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.

hm, why is c := chan Message{} needed, and why there is not a warning, that it is not used later?

Comment thread vlib/v/gen/c/if.v
Comment on lines +204 to +206
defer {
g.last_if_option_type = tmp_if_option_type
}

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.

move the defer after line 197

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.

it will be much less error prone that way, and it will work when the defer becomes scope based

@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 marked this pull request as ready for review February 15, 2025 20:53
@spytheman spytheman merged commit f4aa139 into vlang:master Feb 15, 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.

C compilation error with generics and nested if expressions

2 participants