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

List concatenation bug #3166

Open
samwestmoreland opened this issue May 16, 2024 · 1 comment · May be fixed by #3167
Open

List concatenation bug #3166

samwestmoreland opened this issue May 16, 2024 · 1 comment · May be fixed by #3167

Comments

@samwestmoreland
Copy link
Contributor

MRE:

fruit = [
    "apple",
    "banana",
]

fruit_and_veg = fruit + [
    "edamame",
    "fennel",
]

fruit_veg_and_canned_food = fruit_and_veg + [
    "tuna",
    "baked beans",
]

fruit_veg_canned_food_and_sweets = fruit_veg_and_canned_food + [
    "haribo",
]

fruit_veg_canned_food_and_drinks = fruit_veg_and_canned_food + [
    "matcha latte",
]

fail(', '.join(fruit_veg_canned_food_and_sweets))
apple, banana, edamame, fennel, tuna, baked beans, matcha latte

During the assignment/concatenation of "matcha latte" to the last list, the fruit_veg_canned_food_and_sweets list gets modified. There would appear to be something going on here with a shared underlying slice but I can't seem to get to the bottom of it. Also I can't seem to reproduce it with fewer concatenations than the above, weirdly, if anyone was wondering why there are so many.

@zgeor
Copy link

zgeor commented May 16, 2024

It looks like the +haribo list is not used in the above code example. Instead you are skipping it during the last concatenation

@peterebden peterebden linked a pull request May 16, 2024 that will close this issue
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 a pull request may close this issue.

2 participants