Local names and top-level names as the compiler binds them

- Scope: a run of body defs and defuns is one recursive group; pattern
  parameters; a let of plain names; with-open in sequence; :as; a named
  loop's name; def*, begin and :leave arms. A :view's step, a loop's =>
  call and a comprehension's head are not binders.
- Symbols: a pattern def or def* gives what it binds; :alias; a
  def/grammar's productions and cases; unit forms as constants.
- Completion: the special forms as the compiler has them now.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-11-09 15:02:46 +01:00
parent 78d18c9854
commit 9a365b260b
5 changed files with 474 additions and 44 deletions

View file

@ -14,7 +14,9 @@ their own below; besides those, it does these:
as far as its head, `(defun` or `(match`.
- An outline (`textDocument/documentSymbol`): the file's top-level
definitions, with a type's constructors or fields, a trait's methods and an
`impl`'s functions under them.
`impl`'s functions under them. A `def` or `def*` of a pattern gives the
names it binds, an `(:alias new old)` its new name, and a `def/grammar`
its productions, each a type with the cases of its `:or`.
- Go to definition (`textDocument/definition`): a local name goes to where
it is bound, the innermost binding of it; a top-level name to the file's
own definition, else one in a module it imports or includes, searched
@ -92,11 +94,21 @@ where they were and are sent; the ones after it wait for the check. When it
has run, the server asks the editor to ask again
(`workspace/inlayHint/refresh`), if the editor says it can be asked.
Local names are the ones the parser's own forms bind: parameters of a
`defun`, `fun` and the other `def…` heads, `let`, `let*`, `letrec`,
`let/mono`, named `let` and `with-open` bindings, `with-return`, `match`
patterns, the clauses of `loop`, `seql` and a comprehension, and `def` or
`defun` inside a body, for the forms after it.
Local names are the ones the parser's own forms bind, with its scoping:
- parameters of a `defun`, `fun` and the other `def…` heads, a pattern
parameter `(Tuple a b)` included;
- `let`, `let*`, `letrec`, `let/mono`, named `let` and `with-open`
bindings (`with-open` one after another, as `let*`), a tuple of plain
names `((a b) pair)` included;
- `with-return`, and `match` patterns, where a `(:view step p)` binds what
`p` binds;
- the clauses of `loop`, `seql` and a comprehension, `:as` included, a
named `loop`'s name, and a `:subloop` form's `=> (name expr)`;
- `def`, `def*` and `defun` inside a body, also in a `(begin ...)`, for
the forms after it. A run of `def`s and `defun`s is one recursive group,
as the compiler makes it, so a local function sees itself and the
definitions after it in the run;
- the arms after a `def`'s `:leave`, over their bodies.
## Rename
@ -267,8 +279,9 @@ With eglot instead:
- Completion of record fields after `record-ref`, of module paths in an
`import`, or of keyword arguments. A string that began on an earlier line
is not seen as one, so a multi-line string gets completions.
- Find references, and renaming an exported name, a keyword parameter, a
type, a constructor, a field or a trait method (see "Rename").
- References in other modules, and renaming an exported name, a keyword
parameter, a type, a constructor, a field or a trait method (see
"Rename").
- More than one project. A server serves the project of the first file it is
asked about; see "Projects" above.
- Stale imports are built by the installed compiler, which was tested only