Open arthurevans opened 5 months ago
Should I raise a PR updating the other param and adding test case for the length?
@ConnorGray thoughts here? If I recall correctly, you added this somewhat recently in Q1.
@past-moon l2
is not copied if it's not being used again, even if the transfers operator is omitted.
Bug description
When looking at https://github.com/modularml/mojo/pull/2182/files I was trying to find existing methods that do something similar (consume another value) to see how we've documented this in the past.
Looking at
extend()
, which does something (sort of) similar, we're trying to putother
in an invalid state by setting its size to 0.https://github.com/modularml/mojo/blob/main/stdlib/src/collections/list.mojo#L205
The problem is,
other
isowned
, so we're actually modifying a copy, not the original. I think if we want to modify the original,other
should actually be passed asinout
. (Note that the unit tests forList.extend()
don't test the length ofother
after the call.)Steps to reproduce
Run the following code:
Note that after calling
extend()
, l2's length is unchanged.System information