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
The unsafe/foreign gate misses an @unsafe dependency that appears only in a datatype's is Kind(..) #1205
Put the same @unsafe call in two positions — a def body, and a datatype's kind — and ran --verdict on each.
What happened
A minimal pair, identical but for where the call sits:
# control.bend — the reference sits in a defimportBasedefqsize(j: Array<Nat>) ->Quant:
matchj:
caseALeaf{value}: &1caseANode{xs, ys}: &1defqv() ->Quant:
qsize(Array.join(Nat, ALeaf{0n}, ALeaf{0n}))
type DisKind(qv()):
Mk{}
defuse(d: D) ->Nat:
matchd:
caseMk{}: 0n
# attack.bend — the identical expression inlined into the kindimportBasedefqsize(j: Array<Nat>) ->Quant:
matchj:
caseALeaf{value}: &1caseANode{xs, ys}: &1typeDisKind(qsize(Array.join(Nat, ALeaf{0n}, ALeaf{0n}))):
Mk{}
defuse(d: D) ->Nat:
matchd:
caseMk{}: 0n
$ bend control.bend --verdict
SOME PROOFS FAIL
Error: 1 def relies on unsafe or foreign code:
- qv (exit 1)
$ bend attack.bend --verdict
ALL PROOFS CHECK (exit 0)
Array.join is @unsafe (base.bend:2323-2325).
book_promises (main.ts:733) gathers each tld's references with:
For an ADT it walks each constructor's type c.T and never the datatype's own kind t.T, although ADT carries one (bend.ts:316: { $: "ADT"; n; g; T: HTerm; c: Ctrs; b? }).
Two consequences:
A kind's references never enter uses, so the promise flood never reaches the datatype or its users;
For a zero-constructor datatype t.c is [], so the loop body never runs and nothing about that declaration is walked at all.
Expected
A datatype's kind is part of its meaning — it is what spec_of/root_cols reduce — so it should be walked like a constructor field type.
Suggested fix (one line, tested)
- for (const c of t.$ === "ADT" ? t.c : [t]) {+ for (const c of t.$ === "ADT" ? [t, ...t.c] : [t]) {
With this fix, attack.bend gives 2 defs rely on unsafe or foreign code: - D - use, exit 1, and control.bend is unchanged.
Activity
A closed quantity goes out as its literal, as bend2 computes it, so a…
A closed quantity goes out as written again: --verdict does not trust…
A closed quantity goes out as its literal, as bend2 computes it, so a…
A closed quantity goes out as written again: --verdict does not trust…
A closed quantity goes out as its literal, as bend2 computes it, so a…
A closed quantity goes out as written again: --verdict does not trust…
Track unsafe dependencies in datatype kinds (#1205) (#1220)