Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: fix option if expr with noreturn fn call (fix #22467) #22470

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Oct 10, 2024

This PR fix option if expr with panic() call (fix #22467).

  • Fix option if expr with panic() call.
  • Add test.
fn main() {
	mut x := ?string(none)
	x = if true {
		''
	} else {
		panic('')
	}
	println(x)
}

PS D:\Test\v\tt1> v run .
Option('')

vlib/v/gen/c/cgen.v Outdated Show resolved Hide resolved
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman changed the title cgen: fix option if expr with panic() call (fix #22467) cgen: fix option if expr with noreturn fn call (fix #22467) Oct 10, 2024
@spytheman spytheman merged commit d3b380b into vlang:master Oct 10, 2024
78 checks passed
@yuyi98 yuyi98 deleted the fix_if_expr_with_panic branch October 10, 2024 11:49
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.

cgen error for an if expression, with a panic() call in the else branch, assigned to a ?string variable
2 participants