lib/strings+test: compare returns int, not i32

Hare's strings::compare returns int (ref/hare/strings/compare.ha:12).
Result is a sign, not an index, so the i32 was cargo-culted from the
str-index type. Callsites already compared against 0, so callers
needed no migration. Widened the two return-site casts (u8→int,
i32→int) — the latter avoids i32 underflow on adversarial length
diffs. Added a multibyte test row contrasting ASCII vs UTF-8 lead
byte to exercise the high-bit-operand path.
This commit is contained in:
2026-05-19 22:39:05 +09:00
parent 031f5f9ec8
commit f827429215
5 changed files with 25 additions and 20 deletions

View File

@@ -584,6 +584,7 @@ fn streq(a: str, b: str) bool = {
if (strings.compare("AB", "ABC") >= 0) { fail(); };
if (strings.compare("BCD", "ABC") <= 0) { fail(); };
if (strings.compare("ABC", "abc") >= 0) { fail(); };
if (strings.compare("ABC", "こんにちは") >= 0) { fail(); };
};
// ---- sub / bytesub ----------------------------------------------------