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:
parent
471b49d9e4
commit
bcfcc5500b
3 changed files with 18 additions and 6 deletions
|
|
@ -192,8 +192,7 @@ With eglot instead:
|
|||
location in the message.
|
||||
- Hover for a special form (`record-ref`, `loop`, `match`), which has no
|
||||
definition to find and no doc.
|
||||
- The type of an expression that is not a name, and of a local `defun`'s
|
||||
name where it is defined, which is not seen as a local there.
|
||||
- The type of an expression that is not a name.
|
||||
- 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.
|
||||
|
|
|
|||
9
Scope.fs
9
Scope.fs
|
|
@ -198,9 +198,16 @@ and private inBody (line: int) (column: int) (env: Binder list) (forms: SExpr li
|
|||
match forms with
|
||||
| [] -> env
|
||||
| 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 @ definedBy form) rest
|
||||
| None -> go (env @ defined) rest
|
||||
|
||||
go env forms
|
||||
|
||||
|
|
|
|||
|
|
@ -519,7 +519,8 @@ INFERRED = """(import (std prelude))
|
|||
(: annotated (-> int int))
|
||||
(defun (annotated k)
|
||||
(def (: m int) (+ k 1))
|
||||
m)
|
||||
(def bumped (+ m 1))
|
||||
bumped)
|
||||
"""
|
||||
|
||||
# One declaration that does not check, and one that does.
|
||||
|
|
@ -582,6 +583,11 @@ def inferred(server, tmp):
|
|||
and labels.get("s") == ": string",
|
||||
found,
|
||||
)
|
||||
expect(
|
||||
"inlay hints: a def and a defun in a body, at their names",
|
||||
labels.get("bumped") == ": int" and labels.get("twice") == ": (-?-> string int)",
|
||||
found,
|
||||
)
|
||||
expect(
|
||||
"inlay hints: none for a top-level function's parameters",
|
||||
"xs" not in labels and "names" not in labels and "k" not in labels,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue