Beef
Beef copied to clipboard
Wrong `write-past-end error` when using append fields
Code to reproduce:
class Program
{
class Hash
{
int8 _codec;
uint8[] _hash ~ delete:append _;
public Span<uint8> Hash => _hash;
public int Length => _hash.Count;
[AllowAppend]
public this(Span<uint8> data)
{
let tmp = append uint8[data.Length];
_hash = tmp;
data.CopyTo(this._hash);
}
}
class CID
{
Hash _mhash ~ delete:append _;
[AllowAppend]
public this()
{
uint8[32] data = .();
Hash hash = append .(data);
this._mhash = hash;
}
}
static void Main()
{
CID cid = new .();
delete cid;
}
}
Result:
Memory deallocation detected write-past-end error in 101-byte object allocation
Just to note if int8 _codec; is removed the code works as expected.
Tested with: (Nightly 04/28/2024) Build aa4f9f7dfa8f2ad81a6807b87192516d0ce72a1a