Repository navigation
Resolve BendTT recursive groups by membership (#1212) - #1215
Conversation
|
Joint verification of #1215, #1216, #1218, #1219 and #1220 against main commit 0187512:
The cluster-wide corpus gates were not run; this evidence is the local repository gate, actual CLI/compiler runs and actual kernel checks. |
|
Thanks for the careful write-up. The crash on g4 is real, and this PR does fix it, but I feel like the new The cause. refs (safe.ts:1111) collects every Ref in a body, including those inside erased arguments. Only later and group_new call it, so a dead reference can form a group, pick a group's leader, or reroute a call. The candidate loop in group_of and the group_new in item_emit both work around that. Neither stops dead references from shaping groups. The new test shows this. Its header says dead references "neither add group members nor select a group's leader". Yet h names L only inside keep's erased -p, and it still ends up a member: L.group gets an .h arm, and the member law relies on that. I was thinking on something like make grouping count only live references. That is option 3 in #1212. A dead forward reference doesn't need a group: item_ref already emits a dead name lazily, and the kernel accepts a dead forward reference. So only live cycles should form groups, like base's String.cmp / String.cmp.fin. Then later(k)[0] can't be an unrelated def, group_of can go back to its one-liner, and you don't need the candidate loop or the item_emit change. I'm not completely sure this is the best option, but I think it's a good exploration path. What has to happen:
Guide: Please drop the GUIDE.md line. It describes how safe.ts works inside, not the language. Placed after "may call a def written below it", it also reads as if forward calls were allowed in checked code, and they aren't. I think it doesn't need a guide line on the topic. Test: The regression test doesn't guard the fix as written. Without the fix, bend still prints 5n and the check still accepts, so gates/test.ts passes. gates/safe.ts scores the TypeError as "bend2 rejects", not as a mismatch. Reverting safe.ts turns no gate red. Suggestions:
|
Erased references must not choose recursive groups or shorten their lead. Use checked argument quantities for membership and back-call traversal, retain live lambda and datatype arguments, and reject inconsistent groups. Restore direct group lookup and remove the implementation-only guide line. Replace the crash-only fixture with a semantic law that produces a real safe-gate mismatch on main and agrees after the fix. Integrate tested main 57b6c15 without changing human-written bend.ts or token caps. Verified with the Lean 4.34 kernel, interpreter, JS, C, repo gate 49/49, independent liveness controls and the 1,538-case local verdict corpus. One existing conversion case remains resource-limited; cluster gates are unavailable and existing TypeScript diagnostics are unchanged.
|
Thanks, both blockers are fixed, and the aggregate run against the parent commit is exactly the check I'd want. One thing the io_strerror fallback exposes: file_size.js calls io_sys().mac in its success path, inside the try. Under node that throws, the catch turns it into io_fail(5), and since io_fail no longer crashes, File.size on a perfectly good file now answers Fail (5, "errno 5") with exit 0. Before, it crashed with Cannot find module 'bun:ffi'. I checked: a small open-then-size program prints size 737 under bun and fail 5 errno 5 under node on this branch. The bug was already there, but this PR makes it silent, so please fix it here: const over = process.platform === "darwin" ? 84 : 75; matches what io_sys().mac checks. Nit: the io_strerror comment names four effects, but 18 go through io_fail. I'd drop the list so it doesn't go stale. |
…f, so -o no longer finds no group for it Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
62b0173 to
9baf299
Compare
…g each field, so a deep literal chain elaborates as fast as on main Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t, so grouping reads liveness from the emitter alone A live cycle is found by item_ref, undone and redone through the group; a pass in which a member was named alone before its group went out runs again with the groups known. calls, later and the liveness-walking refs are gone; back again gives the lead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ope, a group's lead is always its member filled last, and growing a group runs the pass again Also one Reroute catch in args, the undo mark only where an item goes out, the template instances built once, and the Safe fields described. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
The File.size follow-up is now fixed on current main (565d7fd): file_size.js uses process.platform for EOVERFLOW and the strerror comment no longer enumerates effects. I exercised a real File.open -> File.size -> File.close program with a five-byte file under both Bun 1.3.13 and Node 22.23.1; both print size 5 and exit 0, without an FFI shim. The existing file_size_no_ffi fixture also passes its Bun lane. No additional patch is needed for that review point. |
Fixes #1212.
--verdictpacks mutually recursive defs into one BendTT def, a group, because the kernel has no mutual recursion. safe.ts found groups up front throughrefs, which collected every name in a body, including those in erased arguments. A dead forward reference (keep(L(n), n)withkeep(-p: Nat, x: Nat)) could therefore form a group, choose its lead, or route a non-member's call through a group's selector. That gave the three faces in the issue: aTypeErrorcrash, a false MISMATCH, and (with the #1131 name collision) a PASS for a book that computes a different value.Groups are now found by emission itself, which already knows what is live:
item_refemits a live name at once, before its caller, and queues a dead one. A live name that meets an item still going out is a live cycle, exactly the forward reference the kernel would reject, and only there doesregroupform (or extend) a group. A dead reference never forms one.item_refthat began the cycle's outermost member undoes what was emitted since, and its caller redoes the call through the group.backgives its shared parameters as before. A cycle that adds no member (one def, or one group, at other specialized arguments) is out of scope. No separate walk decides liveness.tests/proof/group_dead_forward.bendcovers a non-member's erased reference and a def whose first later reference is dead and unrelated. Its laws make main report a mismatch, and this branch checks.Every existing test elaborates byte-identically under
-o(outputs, exit codes and out-of-scope reasons), so base's groups are exactly as before; whole-corpus elaboration time is unchanged. No changes tobend2/bend.ts; no token caps changed.Gates at 3579b74 (each alone, on the cluster): repo PASS 49/49, test PASS 1527/1527, ping PASS 46/46, perf 110/117 (main: 108/117; this PR touches no runtime or compiler code), safe tests 981 agree / 0 out of scope / 1 false reject (
agree_32, as on main).