Creating a string from a DynamicVector Drops the last character in the vector

This example sums up the question:
fn test_stringify() raises:
var example = DynamicVector[Int8]()
example.append(ord("e"))
example.append(ord("x"))

var container = DynamicVector[Int8]()
for i in range(len(example)):
container.append(example[i])
let stringifed = String(container)
assert_equal("ex", stringifed)
# Unhandled exception caught during execution: AssertionError: ex is not equal to e
fn test_stringify() raises:
var example = DynamicVector[Int8]()
example.append(ord("e"))
example.append(ord("x"))

var container = DynamicVector[Int8]()
for i in range(len(example)):
container.append(example[i])
let stringifed = String(container)
assert_equal("ex", stringifed)
# Unhandled exception caught during execution: AssertionError: ex is not equal to e
Is it assuming it's a null terminated string or something?
1 Reply
duck_tape
duck_tapeOP10mo ago
I'm reasonably sure it's a bug. I made a bugticket here: https://github.com/modularml/mojo/issues/1753
Want results from more Discord servers?
Add your server