mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
fix edge cases
This commit is contained in:
parent
3dd16d2114
commit
19039ea5bd
1 changed files with 10 additions and 1 deletions
|
@ -220,7 +220,7 @@ pub const RocStr = extern struct {
|
|||
const element_width = 1;
|
||||
const old_capacity = self.getCapacity();
|
||||
|
||||
if (self.isSmallStr() or !self.isUnique()) {
|
||||
if (self.isSmallStr() or self.isSeamlessSlice() or !self.isUnique()) {
|
||||
return self.reallocateFresh(new_length);
|
||||
}
|
||||
|
||||
|
@ -1906,6 +1906,15 @@ pub fn fromUtf8RangeC(
|
|||
}
|
||||
|
||||
pub fn fromUtf8Range(arg: RocList, start: usize, count: usize, update_mode: UpdateMode) FromUtf8Result {
|
||||
if (arg.len() == 0 or count == 0) {
|
||||
arg.decref(RocStr.alignment);
|
||||
return FromUtf8Result{
|
||||
.is_ok = true,
|
||||
.string = RocStr.empty(),
|
||||
.byte_index = 0,
|
||||
.problem_code = Utf8ByteProblem.InvalidStartByte,
|
||||
};
|
||||
}
|
||||
const bytes = @ptrCast([*]const u8, arg.bytes)[start..count];
|
||||
|
||||
if (isValidUnicode(bytes)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue