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: perfect if expr with compound conditions #22541

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Oct 16, 2024

This PR perfect if expr with compound conditions.

  • Perfect if expr with compound conditions.
  • Add tests.
type Foo = int | []int

fn works() bool {
	arr := [1, 2, 3]
	a := Foo(2)
	if a is int && arr[a] == 3 {
		println('works')
		return true
	}
	return false
}

fn test_if_expr_with_compound_conds() {
	assert works()
}
type Foo = int | []int

fn works() bool {
	a := Foo(2)
	if a is int && '${a}' == '2' {
		println('works')
		return true
	}
	return false
}

fn test_if_expr_with_compound_conds() {
	assert works()
}
type Foo = int | []int

fn works() bool {
	arr := [1, 2, 3]
	a := Foo(2)
	if a is int && unsafe { arr[..a] == [1, 2] } {
		println('works')
		return true
	}
	return false
}

fn test_if_expr_with_compound_conds() {
	assert works()
}

Huly®: V_0.6-20994

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 merged commit a2e478b into vlang:master Oct 16, 2024
78 checks passed
@yuyi98 yuyi98 deleted the perfect_compound_if_conds branch October 16, 2024 10:33
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.

2 participants