Skip to content

Commit

Permalink
fix: fixed bytes_set_item not accepting an Int as input
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed Aug 11, 2023
1 parent aa9aea0 commit 94247b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions argon/vm/datatype/bytes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ ArObject *bytes_get_item(Bytes *self, ArObject *index) {
idx = BUFFER_LEN(self) + idx;

if (idx < BUFFER_LEN(self))
ret = (ArObject *) UIntNew(BUFFER_GET(self)[idx]);
ret = (ArObject *) IntNew(BUFFER_GET(self)[idx]);
else
ErrorFormat(kOverflowError[0], "bytes index out of range (index: %d, length: %d)",
idx, BUFFER_LEN(self));
Expand Down Expand Up @@ -1072,7 +1072,7 @@ bool bytes_set_item(Bytes *self, ArObject *index, ArObject *value) {

idx = ((Integer *) index)->sint;

if (AR_TYPEOF(value, type_uint_))
if (AR_TYPEOF(value, type_int_) || AR_TYPEOF(value, type_uint_))
rvalue = ((Integer *) value)->uint;
else if (AR_TYPEOF(value, type_bytes_)) {
auto *other = (Bytes *) value;
Expand Down Expand Up @@ -1186,7 +1186,7 @@ ArObject *bytes_mod(Bytes *left, ArObject *args) {
if ((buffer = fmt.Format(&out_length, &out_cap)) == nullptr) {
auto *err = fmt.GetError();

argon::vm::Panic( err);
argon::vm::Panic(err);

Release(err);

Expand Down Expand Up @@ -1645,7 +1645,7 @@ ArObject *bytesiterator_iter_next(BytesIterator *self) {

self->index++;

return (ArObject *) UIntNew(byte);
return (ArObject *) IntNew(byte);
}

SHARED_UNLOCK(self->iterable);
Expand All @@ -1665,7 +1665,7 @@ ArObject *bytesiterator_iter_next(BytesIterator *self) {

self->index++;

return (ArObject *) UIntNew(byte);
return (ArObject *) IntNew(byte);
}

TypeInfo BytesIteratorType = {
Expand Down

0 comments on commit 94247b2

Please sign in to comment.