A name a body form defines is bound where it is written

A def, a pattern def and a defun in a body made their names visible to the
forms after them only, so at the name itself nothing bound it: no inlay
hint, and no local hover. A position on such a name is now that name's
binding.

🤖 Generated with [ECA](https://eca.dev)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-10-22 14:03:56 +02:00
parent 471b49d9e4
commit bcfcc5500b
3 changed files with 18 additions and 6 deletions

View file

@ -198,9 +198,16 @@ and private inBody (line: int) (column: int) (env: Binder list) (forms: SExpr li
match forms with
| [] -> env
| form :: rest ->
match inForm line column env form with
| Some found -> found
| None -> go (env @ definedBy form) rest
let defined = definedBy form
// On a name the form defines, that is where the name is bound.
// Anywhere else in the form, the name is not in scope yet.
match defined |> List.tryFind (fun b -> holds line column b.Range) with
| Some own -> env @ [ own ]
| None ->
match inForm line column env form with
| Some found -> found
| None -> go (env @ defined) rest
go env forms