lib: retire os.assert/abort shims — assert/abort are builtins (#58 respell)
The flat checker scope makes ANY decl named assert/abort anywhere in the combined unit disable the builtin unit-wide (the #45 shadow shape: scope_lookup_prefer's cross-module fallback finds it). lib carried three colliding @symbol("rt_abort") shims (os, time, strconv/stof) plus the os.assert wrapper, so a bare assert(cond) in ANY program importing os mis-bound os.assert and failed arity — a hard blocker for regex fold-5 (regex.ha:660/670 bring builtin-assert mass). Ruled respell-now per the recurrence test (#45 -> #58). Delete the shims and the os.assert wrapper; every bare abort(msg) caller (regex, strings, utf8, hash, getopt, encoding/*, time, stof) now lands on the builtin, and the ~40 os.assert(c, m) sites respell to the builtin assert(c, m) — restoring the exact Hare spelling the lib ports diverged from (e.g. ref/hare/bytes/tokenize.ha:23). os.assert had no Hare counterpart (Hare's assert is a language builtin); rule-9 wrapper removed. temp/dirs/bufio already use the non-colliding rtabort spelling and keep it. Now-dead 'import os;' lines kept (pre-existing precedent: lib/strconv/strconv.ww carries one); a tree-wide dead-import sweep is a separate concern. regex.ww's if+abort workarounds citing #58 stay for the fold-5 owner to fold back into assert. combined.ww regenerated for all five selfhost tools + the smoke fixture via make.
This commit is contained in:
@@ -223,7 +223,7 @@ fn utf8bytelenbounded(it: *iterator, end: i32) i32 = {
|
||||
// defaulting end=END is omitted: ww has no default-parameter syntax
|
||||
// (filed as #37). Byte-indexed counterpart: [[bytesub]].
|
||||
export fn sub(s: str, start: i32, end: i32) str = {
|
||||
os.assert(start <= end, "strings.sub: start is higher than end");
|
||||
assert(start <= end, "strings.sub: start is higher than end");
|
||||
let it: iterator = iter(s);
|
||||
let starti: i32 = utf8bytelenbounded(&it, start);
|
||||
let endi: i32 = utf8bytelenbounded(&it, end - start);
|
||||
@@ -239,8 +239,8 @@ export fn sub(s: str, start: i32, end: i32) str = {
|
||||
// codepoint); the equivalent Hare predicate is `s[i] & 0xc0 == 0x80`
|
||||
// at ref/hare/strings/sub.ha:72-73.
|
||||
export fn bytesub(s: str, start: i32, end: i32) (str | utf8.invalid) = {
|
||||
os.assert(start <= end, "strings.bytesub: start is higher than end");
|
||||
os.assert(end <= s.len, "strings.bytesub: end exceeds string length");
|
||||
assert(start <= end, "strings.bytesub: start is higher than end");
|
||||
assert(end <= s.len, "strings.bytesub: end exceeds string length");
|
||||
if (start < s.len && (s[start] & 0xC0u8) == 0x80u8) {
|
||||
let e: utf8.invalid; return e;
|
||||
};
|
||||
@@ -668,7 +668,7 @@ export fn tokenize(s: str, delim: str) tokenizer = {
|
||||
let d: []u8 = toutf8(delim);
|
||||
let i: i32 = 0;
|
||||
for (i < d.len) {
|
||||
os.assert((d[i] & 0x80u8) == 0u8,
|
||||
assert((d[i] & 0x80u8) == 0u8,
|
||||
"strings.tokenize cannot tokenize on non-ASCII delimiters");
|
||||
i += 1;
|
||||
};
|
||||
@@ -682,7 +682,7 @@ export fn rtokenize(s: str, delim: str) tokenizer = {
|
||||
let d: []u8 = toutf8(delim);
|
||||
let i: i32 = 0;
|
||||
for (i < d.len) {
|
||||
os.assert((d[i] & 0x80u8) == 0u8,
|
||||
assert((d[i] & 0x80u8) == 0u8,
|
||||
"strings.rtokenize cannot tokenize on non-ASCII delimiters");
|
||||
i += 1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user