Open helehex opened 2 months ago
I think we can put this bug on hold until small buffer optimisation and small string optimisation land, then we'll have more options to fix the bugs and some of them might not even exist anymore
Agreed. I'd punt on this for a little bit until the SSO/SBO work lands. We should totally figure out our longer-term null-terminated string strategy and FFI once that dust settles.
Bug description
This has to do with how the default initializer creates a null pointer, but initializers with
capacity=0
will still callalloc(0)
, andList.__copyinit__()
always calls the one with capacity.This could be solved on multiple different levels:
List.__copyinit__()
and using the default initializer in that case.String
level, or use the buffers length inString.__len__()
instead of checking the state of the buffers underlying pointer. But this may not solve all the issues.alloc(0)
in the default initializer ofList
capacity=0
in theList
initializer and give a null pointer instead, but it might be nice for empty lists to have an identity/addressalloc(0)
give a null pointer, but that's probably not the bestList
gets SBO, this problem may go away as long as things are handled properlySteps to reproduce
System information