Print an error when attempting to assign to a string index
Why is this needed?
Well, at the moment nothing happens when the user tries something along
the lines of
let some_string = 'v', even though we don't allow it.
The variable itself doesn't change, and we don't print any errors.
This patch just makes the function that would assign return an error instead of silently failing.
Why not implement modifying strings by index?
Sure, we could do that, but it's not quite as obvious as it seems. We
support utf8 strings, so modifying the
ith byte obviously doesn't
work, and could potentially make the string invalid. Another option
would be to set the
ith character to whatever is passed in. This is
fine in theory, but it would be an
O(N) operation in the average
case, and we'd have to shuffle all the following chars either further up
or further down the string.
While this may be a desirable ability to eventually have, it will require significantly more work and thought around strings in ion than simply returning an error.