lib/math+encoding: restore Hare loud preconditions (F-Q)

Three lib functions had lost their Hare loud-abort preconditions, so an
out-of-domain argument silently returned garbage instead of aborting:

  random.u32n / random.u64n  assert(n != 0)    ref/hare/math/random/random.ha:26,42
  base64.decodedsize         assert(sz%4 == 0) ref/hare/encoding/base64/base64.ha:597

Source-bundled lib change, identical on both stages (byte-id neutral).
989_libprecond_abort pins each precondition: n=0 / sz%4!=0 abort (rc!=0),
valid args return 0, run on cstage and wwstage.
This commit is contained in:
2026-06-14 23:18:28 +09:00
parent 7d4feac959
commit 46ed712352
4 changed files with 213 additions and 0 deletions

View File

@@ -259,6 +259,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_nullableglobal_reject \
$(BIN)/test_taggedcompoundderef_reject \
$(BIN)/test_taggedcompoundplace_reject \
$(BIN)/test_libprecond_abort \
$(BIN)/test_idxarg_run \
$(BIN)/test_chainidx_run \
$(BIN)/test_tupfieldsize_run \
@@ -766,6 +767,13 @@ $(BIN)/test_taggedcompoundderef_reject: test/wcc/989_taggedcompoundderef_reject.
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_libprecond_abort: test/wcc/989_libprecond_abort.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_taggedcompoundplace_reject (#20/#21, last two members of the
# compound-OP-on-tagged-place reject class): `gs[i] OP= v` / `a[i] OP= v`
# (INDEX, #20) and `g OP= v` (IDENT, #21) on a tagged-union place are