Skip to content

Conversation

@Rob23oba
Copy link
Contributor

@Rob23oba Rob23oba commented May 20, 2025

This PR adds dot auto-completion to many syntactic constructions, including e.g. #print or unfold. A follow-up PR will be necessary for bootstrapping.

Closes #8353

@github-actions github-actions bot added the release-ci Enable all CI checks for a PR, like is done for releases label May 20, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 21, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 21, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 21, 2025
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label May 21, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented May 21, 2025

Mathlib CI status (docs):

@Rob23oba Rob23oba marked this pull request as ready for review May 21, 2025 16:18
@github-actions github-actions bot added the changelog-language Language features and metaprograms label May 21, 2025
@leanprover-community-bot leanprover-community-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels May 21, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 24, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 24, 2025
Comment on lines -22 to -23
syntax grindBwd := "← " <|> "-> "
syntax grindFwd := "→ " <|> "<- "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surely worth its own PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'd rather do bootstrapping once with an unrelated fix than do it twice because of such a small change...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought CI did bootstrapping automatically these days

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no I mean I need to do things after a stage0 update to complete the change.

Copy link
Contributor

@eric-wieser eric-wieser May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kha
Copy link
Member

Kha commented May 28, 2025

Thanks for the in-depth PR. I believe this is not quite going in the right direction though: we should finally fix ident so that it can properly represent trailing dots as missing input.

@Rob23oba
Copy link
Contributor Author

Rob23oba commented May 28, 2025

Hmm how do we make sure then that it doesn't parse trailing dots of e.g. field notation or provide an error for them? (e.g. a.1)

@Rob23oba
Copy link
Contributor Author

Or should we treat erroring on trailing dots as default behavior and use identWithoutTrailingDot or whatever?

@Kha
Copy link
Member

Kha commented May 28, 2025

Field index notation is an interesting edge case, true! It may be best to special-case it in ident.

@Rob23oba
Copy link
Contributor Author

Another problem is Lean.Parser.Term.completion which has it's own error message: "invalid field notation, identifier or numeral expected". I don't think we can get around adding some mechanism to make sure that identifiers in terms have special treatment. Maybe we could keep ident (the token) without trailing dot treatment but add special treatment for trailing dots to the default ident parser. Then we could have a variant that only parses ident (the token). However both of these have an ident antiquotation and correspond to Lean.Ident.

@Rob23oba
Copy link
Contributor Author

Actually no I was just dumb lol I thought that ident would need to produce an error on its own but instead we can just make the ident parser take the position after the "." as the end position in the source info and the end of rawVal but keep the generated name and the position afterwards. Then the parsers that come after that make sure to produce an error message about the dot (or not). So basically we only make sure that the . becomes part of the syntax range and can be reliably detected in the rawVal.

@Rob23oba
Copy link
Contributor Author

Actually no again that would probably not work because then we don't actually consume the dot and thus it doesn't become part of the syntax range when nested into other nodes.

@Rob23oba
Copy link
Contributor Author

Okay so the best I can come up with is that ident (the token) stays and ident (the parser) additionally consumes trailing dots and if it did, produce an error message. Then we provide identBeforeDot which can be used for term and e.g. declId. Both variants would then have the ident antiquot though and produce Lean.Ident nodes while the default ident additionally puts the trailing dot into its rawVal and source info.

@Rob23oba
Copy link
Contributor Author

I'll open a separate PR for a better fix

@Rob23oba Rob23oba closed this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms release-ci Enable all CI checks for a PR, like is done for releases toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No dot completion for identifiers in most cases

4 participants