2.0.34: checking an inline equality mutates a shared partial head and changes acceptance
What I did
On v2.0.34 (7d8a3eb), I checked this Base-free file:
type U is Data:
U{}
def l(A: Type, B: Type) -> Type:
A
def r(A: Type, B: Type) -> Type:
A
type Box<-h: Type -> Type> is Type:
Box{}
def G(-f: Type -> Type -> Type, -g: Type -> Type -> Type) -> Type:
{f == g : Type -> Type -> Type} -> Box<g(U)>
def make() -> G(l, r):
e => Box{}
def delta() -> Box<l(U)>:
make()({==})$ bun bend2/main.ts --check-only repro.bend
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bun bend2/main.ts --verdict repro.bend
ALL PROOFS CHECKWhat happened
Acceptance depends on whether the same equality proof is inline. Replacing the last definition with these two definitions makes 2.0.34 reject the file:
def proof() -> {l == r : Type -> Type -> Type}:
{==}
def control() -> Box<l(U)>:
make()(proof())SOME PROOFS FAIL
Error:
- expected : Box<l(U)>
- observed : Box<r(U)>
Location: controlThe inline reproducer is also a regression from v2.0.33, which rejects it at delta with the same expected Box<l(U)> / observed Box<r(U)> error.
Expected behavior
Checking the inline {==} argument should not mutate the result type used by the surrounding application. Inlining a proof or moving it into a named definition should not change whether this program type-checks.
Notes
This appears to exercise the filled share-cell merge added in 2.0.34. While checking the inline equality, the bare references l and r compare equal by eta expansion. The comparison then aliases/replaces the cached cell for r. The codomain reuses that cell under a partial application, so Box<r(U)> is subsequently observed as Box<l(U)>. With the named proof, that mutation does not occur in the surrounding application and the nominal partial heads remain distinct.
This report is about stateful checker behavior, not a proof of falsehood: l and r are extensionally equal here, which is why the emitted BendTT is accepted by --verdict.
Environment
- Bend:
v2.0.34(7d8a3eb) - System:
Darwin arm64 - Clang:
Apple clang version 21.0.0 (clang-2100.0.123.102)
Source: HigherOrderCO/Bend