Skip to content

checker: fix if expr with empty array init expression (related #22832) - #22841

Merged
spytheman merged 1 commit into
vlang:masterfrom
yuyi98:fix_if_expr
Nov 12, 2024
Merged

spytheman merged 1 commit into
vlang:masterfrom
yuyi98:fix_if_expr

Conversation

@yuyi98

@yuyi98 yuyi98 commented Nov 12, 2024 •

Copy link
Copy Markdown
Member

This PR fix if expr with empty array init expression (related #22832).

  • Fix if expr with empty array init expression.
  • Add test.
fn main() {
	arr1 := ['Peter', 'Bob']
	arr2 := ['Sam', 'Mike']
	typ := 1
	names := if typ == 1 {
		arr1
	} else if typ == 2 {
		arr2
	} else {
		[]
	}
	println(names)
	assert names == ['Peter', 'Bob']
}

PS D:\Test\v\tt1> v run .
['Peter', 'Bob']

Huly®: V_0.6-21286

@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.

Excellent followup work.

@spytheman
spytheman merged commit 55d6920 into vlang:master Nov 12, 2024
@yuyi98
yuyi98 deleted the fix_if_expr branch November 12, 2024 12:27
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