Skip to content

[go1.20] Added copy from slice to array copy #1332

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

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

grantnelson-wf
Copy link
Collaborator

@grantnelson-wf grantnelson-wf commented Jul 23, 2024

The GopherJS transpiler will converts

slice := []byte{1, 2, 3, 4}
array := [4]byte(slice)

into

array = $clone(($clone(slice, arrayType)), arrayType);

the $clone calls the copy method on the array type. The copy method used src.length that is undefined for a slice. I added to the array type copy method to also allow for conversion from slices into arrays. The secondary $clone is from the assignment of an array to an array.

This will fix the issues in net/netip where they are converting slices of different lengths into arrays for ip addresses. This change should fix the last issue in GopherJS Tests so it should pass. Most of CI should pass, but measurement_size.yml will still fail in this PR (it's fixed by another PR).

This is part of #1270

@grantnelson-wf grantnelson-wf requested a review from flimzy July 24, 2024 19:06
@flimzy flimzy merged commit 5b2414c into gopherjs:go1.20 Jul 24, 2024
10 checks passed
@grantnelson-wf grantnelson-wf deleted the sliceToArrayCast branch July 24, 2024 19:23
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