please icon indicating copy to clipboard operation
please copied to clipboard

List concatenation bug

Open samwestmoreland opened this issue 1 year ago • 1 comments

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.

samwestmoreland avatar May 16 '24 10:05 samwestmoreland

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

zgeor avatar May 16 '24 10:05 zgeor