You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IO foreign defs are trusted invisibly: a forged Rfl silently transports Unit{} into F32 arithmetic — the verdict should count foreign defs like it counts ~ instances #874
Two files: ffi_forge_rwt.bend + its JS twin ffi_forge_rwt.js (below; also at Cypoe/bend-probe). bun bend2/main.ts ffi_forge_rwt.bend
What happened
> nan
> exit 0
The checker demands the {Unit == F32 : Type} evidence live (Rwt checks it) but erases it in codegen ([t.f]), so the forged Rfl is never inspected — Unit{} flows into F32.add unchecked. All terms check. is printed with no indication the book's consistency rests on a foreign promise.
Sibling repro (ffi-empty-trap): a foreign def forge() -> IO(Empty) checks clean (ffi_forge_verdict.bend → All terms check.) and fail-stops the runtime when run — IO(Empty) is a payload no honest foreign impl can ever deliver, since Empty has zero constructors.
The ask: #841 already counts ~ instances as unsafe annotations (t.u === true || k.includes("~")). Foreign defs (tld.i set) are the bigger trust boundary and invisible to the same verdict — All terms check, with N foreign defs is the same disclosure applied to FFI. Optionally, IO(E) for ctorless E is statically refusable. (Neither demo is a kernel inconsistency — every lie arrives IO-headed.)
bend.ts's header claims "no closed live inhabitant of Empty" and carves out
only @unsafe. Foreign books aren't carved out, so the stated invariant is
falsified as written. IO(Empty) is also the one foreign payload no honest
implementation can ever deliver to a continuation — provably a lie, not merely
unverified.
JS emitter path only; C build fails earlier at emit-time layout check.
comp.ts:1737 (val_word) — the C emitter tracks value layouts and catches Unit{} (0 words) being read as F32 (1 word) at compile time. Plus the C backend requires a .c twin per foreign def (comp.ts:2733), which this repro doesn't ship — it would die on that too.
This was the only Issue that was left to make (kind of) was this one #874 - regarding FFI, just basically a "neat to look at maybe" (I filed it as "bug" tho. hope that doesn't overstep)
Agreed: a foreign def should not be trusted silently. Shipped in 2.0.18.
The checker reads a foreign def's type, never its code, which is the same promise @unsafe makes. The verdict now seeds its walk with both, so a foreign def and everything that relies on it are named. Your file, unchanged:
$ bend ffi_forge_rwt.bend
All terms check, but 2 defs rely on unsafe or foreign code:
- forge_eql
- main
nan
Base's own effects keep quiet: the mark is on the file's own claims, not on IO.print.
Refusing IO(E) for a constructor-less E is a separate question and is not in this release.
Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
Activity
Cypoe commentedon Sep 19, 2026
Also, just reposting from Discord as it was asked, the harness that discovered this as well as #852 indipendently is here: https://github.com/Cypoe/bend-probe/tree/master/harness
This was the only Issue that was left to make (kind of) was this one #874 - regarding FFI, just basically a "neat to look at maybe" (I filed it as "bug" tho. hope that doesn't overstep)
Bend 2.0.18: the compiler's own names, a dot in a field name, and the…
VictorTaelin commentedon Sep 19, 2026
Agreed: a foreign def should not be trusted silently. Shipped in 2.0.18.
The checker reads a foreign def's type, never its code, which is the same promise
@unsafemakes. The verdict now seeds its walk with both, so a foreign def and everything that relies on it are named. Your file, unchanged:Base's own effects keep quiet: the mark is on the file's own claims, not on
IO.print.Refusing
IO(E)for a constructor-lessEis a separate question and is not in this release.Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
Bend 2.0.18: the compiler's own names, a dot in a field name, and the…