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

Fix list concat overwriting #3167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

peterebden
Copy link
Member

Fixes #3166

Looks like this is due to the slices overwriting since on append they both think they have extra capacity, but are in fact sharing it. A pure Go example: https://go.dev/play/p/pLl6MlMr3V4

This fixes this particular case; I don't think there are others at present, we seem to construct lists with capacity equal to their final size in other instances.

Copy link
Contributor

@samwestmoreland samwestmoreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for the fix 😄

Copy link

@HartBlanc HartBlanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to apply the slices.Clip to the pyFrozenList case a few lines above too?

@@ -363,7 +364,7 @@ func (l pyList) Operator(operator Operator, operand pyObject) pyObject {
}
panic("Cannot add list and " + operand.Type())
}
return append(l, l2...)
return slices.Clip(append(l, l2...))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to apply this change to the pyFrozenList case a few lines above too?

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.

List concatenation bug
4 participants