mojo
mojo copied to clipboard
Bug in the example code in the manual: The __copyinit__ and __moveinit__ special methods
Bug Description
The example code is:
struct MyString:
var data: Pointer[Int8]
# StringRef has a data + length field
def __init__(self&, input: StringRef):
let data = Pointer[Int8].alloc(input.length+1)
data.memcpy(first.data, input.length)
data[input.length] = 0
self.data = Pointer[Int8](data)
def __del__(owned self):
self.data.free()
The following line is wrong:
data.memcpy(first.data, input.length)
should have been
data.memcpy(input.data, input.length)
Steps to Reproduce
Context
Thanks for filing! @ZolotukhinM can you fix this plz?
This should be fixed in the next update, thanks for the report!
This this be closed @ZolotukhinM ?
I moved it to "Ready" and was going to close it when we release the next update, but I can close now!