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

checker, cgen: fix if/match expr with continue in branch (fix #18457) #18466

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jun 16, 2023

This PR fix if/match expr with continue in branch (fix #18457).

  • Fix if/match expr with continue in branch.
  • Add test.
fn main() {
	mut result := []int{}
	for i in 0 .. 10 {
		s := if i < 2 {
			100 + i
		} else {
			continue
		}

		println(s)
		result << s
	}
	println(result)
	assert result.len == 2
	assert result[0] == 100
	assert result[1] == 101
}

PS D:\Test\v\tt1> v run .
100
101
[100, 101]

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.

Good work.

@spytheman spytheman merged commit ac32d2a into vlang:master Jun 16, 2023
49 checks passed
@yuyi98 yuyi98 deleted the fix_if_expr_continue branch June 16, 2023 10:00
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.

Wrong error when use if expression and continue inside else
2 participants