Skip to content

prototype #1632.1: suggest the closest names on an unknown name - #1731

Closed
adeerkhan wants to merge 3 commits into
bendlang:mainfrom
adeerkhan:proto/1632-1-name-suggestions
Closed

adeerkhan wants to merge 3 commits into
bendlang:mainfrom
adeerkhan:proto/1632-1-name-suggestions

Conversation

@adeerkhan

@adeerkhan adeerkhan commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

This is a prototype for proposal 1 of #1632 (a misspelt name), 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-1-name-suggestions on the fork, 30a87a7d, rebased on main; the repo gate is green.
The note is added at the unknown-name throw in infer-ref (bend.ts:3359), so nothing runs on success. Candidates are book.tlds keys within edit distance 2 of the full displayed key, same namespace first — and when any same-namespace name matches, only those are listed, which keeps Nat.ad down to Nat.add. I skip internal keys (~N, leading ., leading _), require the name parts to share their first character unless the difference is a single edit (that suppressed noise like Chan/Map/Nat for a bare nan and IO/Or for _^), and only offer a name the file can see (the root, its own namespace, or an imported one), so the suggestion is one the user can actually write.

On your repro:

SOME PROOFS FAIL
Error:
- expected : a defined name
- observed : Nat.ad
Context:
- n : Nat
Location: double
3 | def double(n: Nat) -> Nat:
4>|   Nat.ad(n, n)
  |   ^^^^^^
5 | 
Note: did you mean Nat.add?

Every check-failing test that expects a defined name was run (32). Two change: tests/io/tls_connect_close.bend (TLS.connect → TCP.connect) and tests/flatten/ctor_call_syntax.bend (Aw4 → Nw4, or Rw4). The other 30 typo to names with no near neighbour and keep the old message.

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

Thanks for the prototype and the careful 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,
so a name-suggestion pass (~800 ttok) isn't something we want there right now. It
also conflicts with the do-block note #1865 added at the same throw. The idea stays
recorded in #1632 if we revisit error messages later.

This is probably wanted and at some point we will implement, most likely when Bend is bootstrapped.

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.

2 participants