savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
156 stars 12 forks source link

String and Bytes literals wrongly get null bytes trimmed from end #298

Closed jemc closed 2 years ago

jemc commented 2 years ago

When a String or Bytes literal has multiple null bytes (\x00) at its end, then only one of them ends up in the final string and the rest are getting trimmed.

I suspect this may have something to do with how Crystal handles strings inside the compiler.

jemc commented 2 years ago

This turned out to have nothing to do with null bytes - I got the diagnosis wrong when I wrote up this issue ticket.

In reality the bug I was seeing had to do with byte literals that happen to contain UTF-8 sequences in them, which was affecting the size in Crystal to be different from the bytesize.

See #303 for more information about the fix.