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 dump fixed array on array append (fix #22935) #22940

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Nov 22, 2024

This PR fix dump fixed array on array append (fix #22935).

  • Fix dump fixed array on array append.
  • Add test.
fn main() {
	mut myarr := [][3]u8{}
	myarr << [u8(1), 2, 3]!
	myarr << [u8(4), 5, 6]!
	myarr << [u8(7), 8, 9]!
	println(myarr)
	assert myarr[0] == [u8(1), 2, 3]!
	assert myarr[1] == [u8(4), 5, 6]!
	assert myarr[2] == [u8(7), 8, 9]!

	mut myarr2 := [][3]u8{}
	myarr2 << dump([u8(1), 2, 3]!)
	myarr2 << dump([u8(4), 5, 6]!)
	myarr2 << dump([u8(7), 8, 9]!)
	println(myarr2)
	assert myarr2[0] == [u8(1), 2, 3]!
	assert myarr2[1] == [u8(4), 5, 6]!
	assert myarr2[2] == [u8(7), 8, 9]!
}

PS D:\Test\v\tt1> v run .
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[.\\tt1.v:12] [u8(1), 2, 3]u8{}: [1, 2, 3]
[.\\tt1.v:13] [u8(4), 5, 6]u8{}: [4, 5, 6]
[.\\tt1.v:14] [u8(7), 8, 9]u8{}: [7, 8, 9]
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Huly®: V_0.6-21382

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.

dump() breaks the result array elements on appending fixed arrays
1 participant