Skip to content

prototype #1632.4: name the argument that doesn't shrink - #1734

Closed
adeerkhan wants to merge 3 commits into
bendlang:mainfrom
adeerkhan:proto/1632-4-decreasing-argument
Closed

adeerkhan wants to merge 3 commits into
bendlang:mainfrom
adeerkhan:proto/1632-4-decreasing-argument

Conversation

@adeerkhan

@adeerkhan adeerkhan commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

This is a prototype for proposal 4 of #1632 (a call that does not shrink), in reply to the request to prototype 1–7. It is opened against bendlang/bend for review: bend2/bend.ts is human-written per AGENTS.md, so it is not a merge request as it stands. The branch is proto/1632-4-decreasing-argument on the fork, 4e0b46d7, rebased on main; the repo gate is green.
Changed the self-call descent in infer-ref (bend.ts:3340). The existing loop still decides pass/fail; on failure I compare the arguments against the def's declared parameter names (tele_unbind(def.T)), skip arguments that are literally the unchanged parameter, and report the first that isn't — so the common multi-argument case names the right one. A bare self-reference with no arguments keeps the old message. The argument is quoted as written (the check does not evaluate it) and cut at 60 characters.

Your repro:

SOME PROOFS FAIL
Error:
- message  : loop's 1st argument, 1n+p, is not smaller than a
Context:
- p : Nat
- b : Nat
Location: loop
7 |     case 1n+p:
8>|       loop(1n+p, b)
  |       ^^^^
9 | 
Note: pass a part of a, or mark the def @unsafe to skip the termination check.

The other order reports the second argument:

SOME PROOFS FAIL
Error:
- message  : loop's 2nd argument, 1n+p, is not smaller than b
Context:
- a : Nat
- p : Nat
Location: loop
7 |     case 1n+p:
8>|       loop(a, 1n+p)
  |       ^^^^
9 | 
Note: pass a part of b, or mark the def @unsafe to skip the termination check.

25 existing tests with the old message regenerate (the 6 that stay on it are bare self-references, which fall back).

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

Thanks for the prototype and the write-up. We're going to close this one:
bend.ts is human-written and we're keeping its token budget for the checker
itself, and the current message already says what the rule is and points at
the call. Note also that in the issue's repro nothing is "not smaller": after
case 1n+p: the column is 1n+p, so loop(1n+p, b) passes every argument
as received. Naming one argument there (or a is not smaller than a in
polymorphic_self_recursion) would point at the wrong thing.

The idea stays recorded in #1632 if we revisit error messages later. Probably has some better way do it, but I think the message it's understandable rn for 300 tokens.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants