Skip to content

Delete unreachable tree-walker HOF impls (PR D of ILO-45)#712

Merged
danieljohnmorris merged 2 commits into
nextfrom
feature/eval-audit
May 22, 2026
Merged

Delete unreachable tree-walker HOF impls (PR D of ILO-45)#712
danieljohnmorris merged 2 commits into
nextfrom
feature/eval-audit

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

PR D of ILO-45 — fourth slice of the tree-walker eval-loop deletion. Deletes 864 lines of dead HOF implementations from `src/runtime/mod.rs`.

The HOF builtins (`map` / `flt` / `fld` / `srt 2-3` / `rsrt 2-3` / `ct` / `mapr` / `partition` / `flatmap` / `uniqby` / `grp`) were lifted to native VM + Cranelift dispatch in PRs A/B/C and earlier 3b/3c work. None of them appear in `is_tree_bridge_eligible` any more, and the public engine surface was removed in PR #613. Their tree-walker Rust impls inside `call_function` have been dead code since.

Audit (was originally going to be PR D's only deliverable)

Walked every entry in the current `is_tree_bridge_eligible` (72 non-HOF builtins after PR C). None of them call `eval_body` / `eval_stmt` / `eval_expr` transitively. The only callsites for those eval functions inside `call_function` were:

  1. The user-fn dispatch tail (lines 7299-7430) — entered when `call_function(env, name, args)` is called with a user-defined function name.
  2. The 11 HOF impls listed above — they invoke user lambdas by recursing into `call_function` with the callback's name.

Since (2) is now deleted and (1) is only reachable via (2) from the bridge, the eval loop is genuinely unreachable from the live runtime. PR E can delete it.

What's in the diff

Single commit, one file:

  • `src/runtime/mod.rs` — three cut ranges totalling 864 lines:
    • `srt 2-3` and `rsrt 2-3` impls (with their tree-walker key-then-sort logic)
    • `map` / `mapr` / `flt` / `ct` / `fld` / `partition` / `flatmap` / `uniqby` / `grp` impls
    • The `closure_captures` and `resolve_fn_ref` nested helpers (used only by the deleted impls)
    • 14 `runtime::tests` inline unit tests that exercised the deleted impls via `run_str` (the tree-walker engine entry)

Test plan

  • `cargo test --release --features cranelift` — full suite green
  • No external regression tests fail. The deleted unit tests were tree-walker-engine-specific; cross-engine integration tests (`tests/examples_engines.rs`, `tests/regression_*`) cover the same scenarios on VM + Cranelift and still pass

Follow-ups

  • PR E: delete `eval_body` / `eval_stmt` / `eval_expr` / `Env` user-fn dispatch / trampoline / `ACTIVE_AST_PROGRAM` — the headline LoC win. Will also delete the remaining tree-walker-only tests in `runtime::tests` that exercise `run_str`

PR D of ILO-45. The HOF builtins (map / flt / fld / srt 2-3 / rsrt 2-3 /
ct / mapr / partition / flatmap / uniqby / grp) are no longer reachable
from the tree-bridge: PRs A/B/C/earlier-3b/3c lifted each one to native
VM dispatch and removed them from is_tree_bridge_eligible.

Their tree-walker Rust impls inside call_function were dead code —
nothing in the VM dispatch path routes a HOF call through the bridge
any more, and the engine-Tree CLI surface was removed in PR #613.

Cuts:
  - 12 HOF impl blocks in src/runtime/mod.rs call_function (3803-3854,
    3901-3953, 5715-6186)
  - The closure_captures / resolve_fn_ref nested helpers that only
    those impls used
  - 14 runtime::tests inline unit tests that exercised the deleted
    impls via run_str (the tree-walker engine entry point)

The tree-walker eval loop itself (eval_body / eval_stmt / eval_expr /
Env / trampoline / ACTIVE_AST_PROGRAM) stays for PR E. After this PR,
it is only reachable from the user-fn dispatch tail of call_function,
which is now only reached by other tests in the runtime::tests module
that exercise the tree-walker through run_str. PR E deletes that path
and the eval loop.

864 lines of dead code gone. cargo test --release --features cranelift
green.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

My PR D delete script stripped 14 failing tests but left two artefacts:
- 20 duplicate `#[test]` lines stacked above other tests (the saved-but-
  never-cleared bug in the awk script).
- 6 `run2_*` tests had `#[test]` then `#[cfg(not(target_family="wasm"))]`
  ordering; my awk's pending-attribute logic discarded `#[test]` because
  the next line wasn't `fn`. Restored.

cargo clippy --release --features cranelift -- -D warnings clean.
@danieljohnmorris danieljohnmorris merged commit fe0e95c into next May 22, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the feature/eval-audit branch May 22, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant