Implicit copy of read ref? Documentation problem, right?

Reading through the docs once again for the 100x time probably I found this:

def mutate_copy(l: List[Int]) -> List[Int]:
    # def creates an implicit copy of the list because it's mutated
    l.append(5)
    return l

I immediately was very skeptical and then relieved after trying that this does in fact NOT work.
I guess / hope this is an old relict when we had both fn & def and is hopefully not the intended behavior.

Can someone confirm? :nerd_face:


Also reading through the complete “Mojo Manual” again, there seems to be a lot of old / legacy mojo code that is either

  • not working anymore: e.g. print(list_of_data.__str__()) → print(list_of_data)
  • not using newer features: e.g. "...".format(...) instead of t-String

Looking at the recent update for the contribution process I would assume PRs to improve the docs are welcome? Can also create an issue if necessary! :smiling_face_with_sunglasses: :fire:

Wow, indeed, that is a bug. We’d love it if you could raise issues (here or in the issue tracker) for bugs like that when you see them. @arthur and @erica_sadun fyi.

Thanks for double-checking it and calling it out.

We’ve been doing a lot of cleanup as the language stabilizes, and there are definitely still places where older patterns or syntax have survived longer than they should have. The examples you pointed out are good catches.

And yes, PRs to improve the docs are absolutely welcome. Issues are helpful too, especially for broader cleanup or consistency work. Thanks for taking the time to reread things this carefully