-
Notifications
You must be signed in to change notification settings - Fork 3
Description
stringview_wtf16.get_codeunit will trap on an invalid offset. However stringview_wtf16.encode or stringview_wtf16.slice will clamp operands within range. Should we make these more consistent?
One thing is that for stringview_wtf16.encode, there is a reasonable "null" answer that overlaps with the normal behavior: encoding nothing. Similar with slices. Whereas for stringview_wtf16.get_codeunit I guess you would define that -1 would be the exceptional answer, which, maybe it could "leak" to other parts of your program, e.g. if you mindlessly store it via i32.store16 to write U+FFFF. Also, the compiler can use the fact that out-of-range would throw to make an inference about the string length. But, these are relatively minor concerns, I think.