Skip to content

A + binder in a nested tuple let fails with 'an annotated term (cannot infer)' when the goal mentions the pair #1077

Open

Description

@paymog

What I did

Bend 2.0.28 on macOS 26 (darwin 25.6.0), arm64. bend update reports no newer version.

import Base

def third(r: U32 & Bool & List<&2, U32>) -> List<&2, U32>:
  (a, b, c) = r
  c

def lemma(r: U32 & Bool & List<&2, U32>) -> {third(r) == third(r) : List<&2, U32>}:
  (a, rest) = r
  (b, +c) = rest
  {==}
bend pair.bend

What I expected

All terms check. The file checks when +c is written as c.

What happened

Error:
- expected : an annotated term (cannot infer)
- observed : _ => List<&2, U32>
Context:
- a : U32
- b : Bool
Location: lemma
127 | def Pair(-A: Type, -B: Type) -> Type:
128>|   Sigma<&1, &1, A, _ => B>

It needs all three parts:

  • a + on a binder in a tuple let,
  • a let on a pair that came out of an earlier tuple let (rest), and
  • a goal that mentions the outer pair r, so the checker refines it.

A flat (a, +c) = r checks, and so does (a, b, c) = r without +. This looks like the tuple-let path of #810: that fix moved + onto the binder for braced patterns, and the observed term is the Pair family lambda, which does not infer.

Workaround

Bind the components without + and pass them to a helper that takes + parameters.

Activity

  1. paymog commented on Sep 27, 2026

    @paymog
    Author

    Another reproduction on Bend 2.0.31 (macOS 26, arm64). It is smaller: a flat triple, no goal that mentions the pair.

    import Base
    
    def f(r: U32 & U32 & U32) -> U32:
      (a, +i, +c) = r
      (i + c + i + c : U32)
    
    def main() -> U32:
      f((1, 2, 3))

    bend t.bend fails with the same an annotated term (cannot infer) / observed : _ => U32 at Pair. (+a, +i, +c) = r fails too, and so does (a, +i, c0) = r followed by +c = c0. (a, +i, c) = r with c used once checks and prints 7.

  2. added
    later
    on Sep 27, 2026
  3. paymog commented on Oct 28, 2026

    @paymog
    Author

    Still present on Bend 2.0.38 (macOS 26, arm64). Here, + binds the last field of a triple whose first two fields are affine (Type) values:

    type Br is Type:
      Br{r: Bits.Reader, bad: Bool}
    
    def f(+x: U32, b: Br) -> Br:
      b
    
    def g(r: Bits.Huff & Br & U32) -> Br:
      (h, b, +s) = r
      f(s, b)

    The check fails with an annotated term (cannot infer) / observed : _ => U32 at Pair. A two-step bind (h, bs) = r then (b, +s) = bs fails the same way. (b, +s) = bs on a parameter bs: Br & U32 checks. Workaround: bind s without + and pass it to a helper that takes +s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    later

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions