lean4-htt/tests/lean/10488.lean
Robert J. Simmons 5326530383
feat: suggestions for ambiguous dotted identifiers (#11555)
This PR scans the environment for viable replacements for a dotted
identifier (like `.zero`) and suggests concrete alternatives as
replacements.

## Example

```
#example .zero
```

Error message:
```
Invalid dotted identifier notation: The expected type of `.cons` could not be determined
```

Additional hint added by this PR:
```
Hint: Using one of these would be unambiguous:
  [apply] `BitVec.cons`
  [apply] `List.cons`
  [apply] `List.Lex.cons`
  [apply] `List.Pairwise.cons`
  [apply] `List.Perm.cons`
  [apply] `List.Sublist.cons`
  [apply] `List.Lex.below.cons`
  [apply] `List.Pairwise.below.cons`
  [apply] `List.Perm.below.cons`
  [apply] `List.Sublist.below.cons`
  [apply] `Lean.Grind.AC.Seq.cons`
```

## Additional changes

This PR also brings several related error message descriptions and code
actions more in line with each other, changing several "Suggested
replacement: " code actions to the more common "Change to " wording, and
sorts suggestions obtained from searching the context by the default
sort for Names (which prefers names with fewer segments).
2025-12-09 17:27:22 +00:00

60 lines
1.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#eval (1,(2,3)).2.fst
#check 31.
#check 31.0
#eval 31.
#eval 31.0
#check 31.e
#check 31.ee
#check 31.f
#check 31.ff
#check 31.3e
#check 31.3e2
#check 31.3ee2
#check 31.3f
#check 31.3f2
#check 31.3ff2
#check 11.toDigits 13
#check (11).toDigits 13
#eval (11).toDigits 13
#check (11).toDigits(13)
#check (11).toDigits (13)
def succ (a: Nat) := a + 1
def foo {A B} (_: A) (_: B) : Unit := ()
#check foo 31.succ
#check foo (31).succ
#check foo 31(.succ)
#check foo (31)(.succ)
#check foo 31 .succ
#check foo 31. succ
#check 11succ
#check 11.succ
#check 11.12succ
#check (11.succ)
#check (11.12succ)
-- This example (adapted from structInst4.lean) exercises the difference betwee
-- term parsing and LVal parsing; the latter fails if we allow `2.snd` to parse
-- as a scientificLit followed by an error token, so this test captures
-- that we have to throw the error token right away, positioned before, rather
-- than after the `2.`
structure Foo where
(x : Nat × (Nat × Nat) := (2, (4, 5)))
def bar : Foo := {}
#check bar.x.2.snd
#eval { bar with x.2.snd := 1 }
inductive Nope where
| succ : Nope -> Nope -> Nope
| leaf : Nope
example := (match · with
| succ x y => 4)