-
Notifications
You must be signed in to change notification settings - Fork 205
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
Conversation
There was a problem hiding this 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 😄
There was a problem hiding this 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...)) |
There was a problem hiding this 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 this change to the pyFrozenList case a few lines above too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't hurt, thanks!
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.