lib: port errors.errno + os errno/strerror sys-layer (#6)
Hare-faithful port of errors::errno (ref/hare/errors/{rt,common,opaque}.ha): the 13 named common error conditions, opaque_data/opaque_ (the type-erased tail whose strerror fn-ptr defers to os.strerror), and errno(os.errno) error mapping the ~12 mapped errnos to named conditions and wrapping the unmapped tail in opaque_. The raw errno type (!i32, kernel-int width, distinct from oserror's !i64 negative raw return), the E* constants, and the strerror message table live in lib/os: ww folds Hare's sys role into os, so os is the import floor that lib/io and lib/errors build on -- documented in lib/CLAUDE.md (os never imports io or errors). errors.error is explicitly enumerated, matching Hare; the ...errors::error spread is only io.error's (blocked by #199b). Prereq for post-eFinal #5's faithful io error mapping; retires the nomem-collapse interim. Adds errnotest (mapping / opaque-tail / strerror) + test/wcc/902_errno_run. Landing required two wwstage cgen fixes (#9 struct-variant-large-union return, #11 deref-store alias narrow). Divergences cited at-site: bare-type-name return -> let+return; switch fall-through vs Hare's exhaustiveness-only default; opaque_ const dropped.
This commit is contained in:
@@ -53,7 +53,12 @@ Modules with intentional divergence:
|
||||
- `lib/os` and `lib/net` stay below the Hare abstraction — they are
|
||||
syscall wrappers, not the high-level `io::handle` / `net::socket`
|
||||
API. Use them as the foundation that `lib/io` and the buffered
|
||||
layers build on.
|
||||
layers build on. `lib/os` also plays Hare's `sys` role (ww folds
|
||||
`sys` into `os`), so it is the import floor: lib/os must never import
|
||||
io OR errors — everything points down to os; os's only edge is the
|
||||
import-free time leaf. This is what lets `errors` import `os` (for
|
||||
`os.errno` / `os.strerror`) without a cycle, mirroring Hare's
|
||||
`sys ← errors`, `sys ← io`.
|
||||
- `lib/io` keeps the ww-specific `stream` struct (vtable of fn
|
||||
pointers, no closures, no methods). The Hare `io::handle` family
|
||||
needs language features we don't have yet.
|
||||
|
||||
Reference in New Issue
Block a user