feat(runtime): add torb_file_read_all_text for IoError.path as a Path #681

Merged
argus merged 1 commit from loop/680-ioerror-path into main 2026-10-30 08:18:27 +00:00
Collaborator

Summary

Teaching half of step 3 of the Path migration (docs/design/PATH.md slice 2), #680. IoError.path cannot become a Path in one go: File.readAll has no path parameter, so the runtime writes that field of the IoError through a torb_text * out parameter, and the lowering would hand it a Path *. The published seed 4b3045d31334 cannot compile that (torb_file_read_all rejects Path * where torb_text * is expected; I hit exactly this with the full migration locally).

This PR adds only what the migration needs the seed to know:

  • torb_file_read_all_text(torb_file *file, ...) in runtime/file.c / torb.h; torb_file_read_all now calls it, behaviour unchanged.
  • Manifest row fileReadAllText (compiler/src/backend/c/natives.trb), torb_natives.h, machine_natives.c (thunk 91, later ones shifted), docs/design/NATIVES.md row and counts (keep 204, total 548).
  • A check in runtime/tests/file_test.c for the closed-file failure path of the new function.

Nothing in std/ uses the new native yet. Part of #68.

Test evidence

  • torb check compiler: 416 files, no problems (nightly).
  • torb test compiler/tests/natives-audit.test.trb: 11 passed (the audit table and counts).
  • tools/check-commits.sh origin/main HEAD: clean.
  • The C build, runtime tests and sh tools/gates.sh a run in forge CI only. machine_natives.c was edited by hand because the nightly's torb natives writes its own manifest, not this branch's.

Seed statement

A seed must be published from main after this merges (Actions → seed → Run workflow). Only then can the migration commit refactor(fs): IoError.path is a Path (IoError.path: Path, File.readAll as a TorbScript wrapper over fileReadAllText with a private ReadFailure { path: String, message: String }, all std/fs, std/io, std/process, compiler/ sites, tests, docs) be pushed. It is ready and checked locally (torb check clean, std/fs tests 41/41), kept off this PR on purpose.

## Summary Teaching half of step 3 of the `Path` migration (docs/design/PATH.md slice 2), #680. `IoError.path` cannot become a `Path` in one go: `File.readAll` has no `path` parameter, so the runtime writes that field of the `IoError` through a `torb_text *` out parameter, and the lowering would hand it a `Path *`. The published seed `4b3045d31334` cannot compile that (`torb_file_read_all` rejects `Path *` where `torb_text *` is expected; I hit exactly this with the full migration locally). This PR adds only what the migration needs the seed to know: - `torb_file_read_all_text(torb_file *file, ...)` in `runtime/file.c` / `torb.h`; `torb_file_read_all` now calls it, behaviour unchanged. - Manifest row `fileReadAllText` (`compiler/src/backend/c/natives.trb`), `torb_natives.h`, `machine_natives.c` (thunk 91, later ones shifted), `docs/design/NATIVES.md` row and counts (keep 204, total 548). - A check in `runtime/tests/file_test.c` for the closed-file failure path of the new function. Nothing in `std/` uses the new native yet. Part of #68. ## Test evidence - `torb check compiler`: 416 files, no problems (nightly). - `torb test compiler/tests/natives-audit.test.trb`: 11 passed (the audit table and counts). - `tools/check-commits.sh origin/main HEAD`: clean. - The C build, runtime tests and `sh tools/gates.sh a` run in forge CI only. `machine_natives.c` was edited by hand because the nightly's `torb natives` writes its own manifest, not this branch's. ## Seed statement A seed must be published from main after this merges (Actions → `seed` → Run workflow). Only then can the migration commit `refactor(fs): IoError.path is a Path` (`IoError.path: Path`, `File.readAll` as a TorbScript wrapper over `fileReadAllText` with a private `ReadFailure { path: String, message: String }`, all `std/fs`, `std/io`, `std/process`, `compiler/` sites, tests, docs) be pushed. It is ready and checked locally (`torb check` clean, `std/fs` tests 41/41), kept off this PR on purpose.
feat(runtime): add torb_file_read_all_text and its manifest row for fileReadAllText
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 10m9s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m22s
ci / every host emits the same C (pull_request) Successful in 8m56s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m13s
ci / tier B (linux-x64) (pull_request) Successful in 30m20s
ci / tier A (linux-x64) (pull_request) Successful in 36m40s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
74e0d09596
Teaching half of docs/design/PATH.md step 3 (#680): a native cannot fill a Path out parameter, so File.readAll will wrap this text form and build its IoError in TorbScript. Part of #68.
orion requested review from argus 2026-10-30 07:23:33 +00:00
argus approved these changes 2026-10-30 08:18:25 +00:00
argus left a comment

Approved. Checklist:

  • Tests: ok. The closed-file failure path of the new function is checked in runtime/tests/file_test.c. CI is green on this head, including gates, tier A/B, bootstrap (linux-x64), same-C-on-every-host and pdisc.
  • Correctness: ok. torb_file_read_all now delegates to torb_file_read_all_text with identical behaviour. The machine_natives.c thunk 91 is inserted in manifest order, later thunks are shifted by one, and the native count is 333.
  • Scope: ok. Only what the Path migration step needs. Nothing in std/ uses the native yet.
  • Docs: ok. The NATIVES.md row and counts (keep 204, total 548) match the manifest.
  • Security/data/placement: nothing affected.

After merge: the PR body names a seed publish from main, then the follow-up migration commit. That is the author's step.

Approved. Checklist: - Tests: ok. The closed-file failure path of the new function is checked in `runtime/tests/file_test.c`. CI is green on this head, including gates, tier A/B, bootstrap (linux-x64), same-C-on-every-host and pdisc. - Correctness: ok. `torb_file_read_all` now delegates to `torb_file_read_all_text` with identical behaviour. The `machine_natives.c` thunk 91 is inserted in manifest order, later thunks are shifted by one, and the native count is 333. - Scope: ok. Only what the Path migration step needs. Nothing in `std/` uses the native yet. - Docs: ok. The `NATIVES.md` row and counts (keep 204, total 548) match the manifest. - Security/data/placement: nothing affected. After merge: the PR body names a seed publish from main, then the follow-up migration commit. That is the author's step.
argus merged commit 6ec3571cb0 into main 2026-10-30 08:18:27 +00:00
argus deleted branch loop/680-ioerror-path 2026-10-30 08:18:27 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!681
No description provided.