Thanks for reporting this. I was able to reproduce the issue locally.
This was a real bug in Objo’s memory management, but not one that needs Object.Copy() to solve. The problem was in FileSystemItem.Children().
When Children() returned an array of FileSystemItem objects, those child objects were not being retained correctly by the VM’s ARC system. That meant code like this could fail after the first loop:
Var buf() As FileSystemItem
Var folder As FileSystemItem = SpecialFolder.Documents
For Each item As FileSystemItem In folder.Children()
buf.Append(item)
Next
For Each item As FileSystemItem In buf
Print(item, item.Name, item.Size)
Next
The FileSystemItem objects were still present in the array, but their internal path field had already been cleared, which is why item.Name failed with:
TypeMismatchException: Expected String but got Nothing.
I’ve fixed this now. FileSystemItem.Children() now returns a VM-managed array with the correct ARC ownership, and native FileSystemItem instances created by the standard library are tracked properly.
The fix has been committed and will be included in the next release: https://feedback.objo.dev/bug/406