Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refine how named arguments suppress explicit arguments #5283

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Sep 8, 2024

Note: Most of the implementation of this PR is at #5512 due to a bad rebase before merging.

Recall that currently named arguments suppress all explicit parameters that are dependencies. This PR limits this feature to only apply to true structure projections, except in the case where it is triggered when there are no more positional arguments. This preserves the primary reason for generalizing this feature (issue #1851), while removing the generalized feature, which has led to numerous confusions (issue #1867). This also fixes a bug pointed out on Zulip where in @ mode, instance implicit parameter dependencies to named arguments would be suppressed unless the next positional argument was _.

More detail:

  • The NamedArg structure now has a suppressDeps : Bool field. It is set to true for the self argument in structure projections. If there is such a NamedArg, explicit parameters that are dependencies to the named argument are turned into implicit arguments. The consequence is that all structure projections are treated as if their type parameters are implicit, even for class projections. This flag is not used for generalized field notation.
  • We preserve the suppression feature when there are no positional arguments remaining. This feature pre-dates the fix to issue Dot notation with typeclass instances issue #1851, and it is useful when combining named arguments and the eta expansion feature, since dependencies of named arguments cannot be turned into eta arguments. Plus, there are examples of the form rw [lem (h := foo)] where lem has explicit arguments that h depends on.
  • For instance implicit parameters in explicit mode, now _ arguments register terminfo and are hoverable.
  • Now .. is respected in explicit mode.

This implements RFC #5397. The suppressDeps flag suggests a future possibility of a named argument syntax that can suppress dependencies.

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 8, 2024 18:45 Inactive
@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 Sep 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 8, 2024
@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 Sep 8, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Sep 8, 2024

Mathlib CI status (docs):

  • 💥 Mathlib branch lean-pr-testing-5283 build failed against this PR. (2024-09-08 19:35:15) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1b6572726fe2418266c5205bda4f0d5573e20229 --onto 0196bca784f82f90b4efd2a85a400daf4ab767f8. (2024-09-27 20:06:48)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 8, 2024 20:08 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 8, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@kmill kmill changed the title fix: improve elaboration of _s for inst implicit arguments in explicit @ mode fix: refine how named arguments suppress explicit arguments Sep 24, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 24, 2024 07:54 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 24, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 24, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 24, 2024 08:14 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 24, 2024
@kmill
Copy link
Collaborator Author

kmill commented Sep 24, 2024

Originally this PR conservatively changed how _ worked for instance arguments in explicit mode. Now it changes how named arguments suppress dependencies in general, starting from a4af20a.

leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 24, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 24, 2024 22:01 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 24, 2024 22:10 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 24, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 24, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 24, 2024 22:37 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 24, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 24, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@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 Sep 25, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 27, 2024 19:10 Inactive
@kmill kmill added this pull request to the merge queue Sep 27, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 27, 2024
… `@` mode

This PR does two things:
1. Recall that in explicit mode, a `_` in place of an instance implicit argument still does instance synthesis (one can use `(_)` instead to turn it into a true implicit argument). There has been missing terminfo for such arguments. Now hovering will display the synthesized expression and its type.
2. Recall that when there are named arguments, every explicit argument the named arguments depend on become implicit. This was interacting badly with instance arguments in explicit mode, since the `_` special casing mentioned above was not respecting this rule. Now it respects this rule.

This PR is operating under the assumption that the named argument feature in item 2 is meant to be active in explicit mode. An alternative to item 2 would be to turn the feature off in explicit mode.
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc September 27, 2024 20:00 Inactive
@kmill kmill added this pull request to the merge queue Sep 27, 2024
Merged via the queue into master with commit 9f4075b Sep 27, 2024
14 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Sep 29, 2024
I did a bad git rebase before merging #5283, which reverted it to an
earlier version. This PR has the actual implementation of RFC #5397.
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 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.

2 participants