Skip to content

Conversation

@robsimmons
Copy link
Contributor

@robsimmons robsimmons commented Dec 10, 2025

This PR switches the way olean files store identifier suggestions. The ordering introduced in #11367 and #11529 made sense if we were only storing incorrect -> correct mappings, but for the reference manual we want to store the correct -> incorrect mappings as well, and so it is more sensible to store just the correct -> incorrect mapping that mimics the author-generated data better.

Also tweaks error messages further in preparation for public-facing @[suggest_for] annotations and forbids suggestions on non-public names.

Does not make generally-visible changes as there are no introduced uses of @[suggest_for] annotations yet.

@robsimmons robsimmons marked this pull request as ready for review December 10, 2025 21:02
@robsimmons robsimmons enabled auto-merge December 10, 2025 21:02
@robsimmons robsimmons added this pull request to the merge queue Dec 10, 2025
@robsimmons robsimmons removed this pull request from the merge queue due to a manual request Dec 10, 2025
@robsimmons robsimmons enabled auto-merge December 10, 2025 21:40
@robsimmons robsimmons added this pull request to the merge queue Dec 10, 2025
Merged via the queue into master with commit 9e87560 Dec 10, 2025
18 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Dec 10, 2025
…11554)

This PR adds `@[suggest_for]` annotations to Lean, allowing lean to
provide corrections for `.every` or `.some` methods in place of `.all`
or `.any` methods for most default-imported types (arrays, lists,
strings, substrings, and subarrays, and vectors).

Due to the need for stage0 updates for new annotations, the
`suggest_for` annotation itself was introduced in previous PRs: #11367,
#11529, and #11590.

## Example
```
example := "abc".every (! ·.isWhitespace)
```

Error message:
```
Invalid field `every`: The environment does not contain `String.every`, so it is not possible to project the field `every` from an expression
  "abc"
of type `String`

Hint: Perhaps you meant `String.all` in place of `String.every`:
  .e̵v̵e̵r̵y̵a̲l̲l̲
```

(the hint is added by this PR)

## Additional changes

Adds suggestions that are not currently active but that can be used to
generate autocompletion suggestions in the reference manual:
 - `Either` -> `Except` and `Sum`
 - `Exception` -> `Except`
 - `ℕ` -> `Nat`
 - `Nullable` -> `Option` 
 - `Maybe` -> `Option`
 - `Optional` -> `Option`
 - `Result` -> `Except`
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