Closed Caid11 closed 1 month ago
Yes, it looks like bytes.c
already handles the len+1
and terminating byte for all internal variants of strings.
https://github.com/koka-lang/koka/blob/b1c558e91afbb39a2388f207df17c384a279cbc1/kklib/src/bytes.c#L18
I'll commit a quick fix on dev.
I think there's an off-by-one error in kk_string_from_chars. When I convert a vector of chars to a string, a space is added to the end of the resulting string.
For example, this snippet:
Produces this output in Koka v3.1.1:
Looking at kk_string_from_chars, I see Koka adds 1 to the length of the vector's elements:
I suspect the intent is to add a terminating character, but perhaps Koka's string implementation adds that implicitly? If I remove the added 1, it seems to produce the correct output.
Here's a complete reproducer:
vec-str-bug-repro.kk:
inline.c:
Resulting output: