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

feat: improve @[deprecated] attr #3968

Merged
merged 3 commits into from
Apr 23, 2024
Merged

Conversation

digama0
Copy link
Collaborator

@digama0 digama0 commented Apr 22, 2024

Complement to #3967 , adds a (since := "<date>") field to @[deprecated] so that metaprogramming code has access to the deprecation date for e.g. bulk removals. Also adds @[deprecated "deprecation message"] to optionally replace the default text "{declName} has been deprecated, use {newName} instead".

@digama0 digama0 requested a review from kim-em April 22, 2024 04:13
@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 Apr 22, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Apr 22, 2024

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e4daca8d6b02677115282abff8515a9afb6a2a29 --onto 62cdb51ed5b9d8487877d5a4adbcd4659d81fc6a. (2024-04-22 04:30:27)
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 7a076d0bd4240b8db8c383d2f2e85103bf4a268e --onto 62cdb51ed5b9d8487877d5a4adbcd4659d81fc6a. (2024-04-23 17:02:37)

@kim-em
Copy link
Collaborator

kim-em commented Apr 22, 2024

Thanks. Could you add two tests for tests/lean/deprecated.lean for the alt-text (it's fine to use #guard_msgs there rather than having to update expected.out) and validating that (since := ...) is accepted?

@kim-em kim-em added the awaiting-author Waiting for PR author to address issues label Apr 22, 2024
@kim-em
Copy link
Collaborator

kim-em commented Apr 22, 2024

I've pulled #3967 off the queue and will update it once this is in.

@digama0
Copy link
Collaborator Author

digama0 commented Apr 22, 2024

The manual is failing and I have no idea how to track down errors in that build step...

@kim-em kim-em enabled auto-merge April 22, 2024 05:03
@digama0
Copy link
Collaborator Author

digama0 commented Apr 22, 2024

@Kha It appears that alectryon is failing because it misses a bug fix not present on the lean4 fork of alectryon. (There is likely another error behind this one, but the one shown in the log seems to be this issue.)

@Kha
Copy link
Member

Kha commented Apr 22, 2024

Can we somehow survive for a little longer without touching Alectryon?

@digama0
Copy link
Collaborator Author

digama0 commented Apr 22, 2024

Could there be some documentation for how to build the manual (without nix)? All I see is some nix stuff I don't understand and a broken error message due to a bug in an abandoned dependency. I don't even know what sources are being built, it's loading some SHAs from the nix cache?

-/
syntax (name := deprecated) "deprecated" (ppSpace ident)? : attr
syntax (name := deprecated) "deprecated" (ppSpace ident)? (ppSpace str)?
(" (" &"since" " := " str ")")? : attr
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you declare since as a separate syntax so that it gets its own docstring (which can recommend the date format)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it is better to have this documentation on deprecated, because otherwise people won't necessarily know that the clause exists in the first place. The example in deprecated gives at least a bare hint of what the date format should be.

@Kha
Copy link
Member

Kha commented Apr 23, 2024

error: builder for '/nix/store/wgi78yspl1dxsx0bkf020v24cbm5fzfh-examples.ICERM2022.ctor.md.drv' failed with exit code 1;

Let's please just fix all deprecation warnings in ICERM2022/ctor.lean and then document everything about the manual when it's redone in Verso

@digama0
Copy link
Collaborator Author

digama0 commented Apr 23, 2024

Let's please just fix all deprecation warnings in ICERM2022/ctor.lean and then document everything about the manual when it's redone in Verso

How did you manage to deduce that this was the problem? That was the issue I was having, the error message is completely opaque.

I'm not idly asking for improvements to the manual, I literally don't know how to track down errors in this build step. I understand that this code is on life support but it's still a required build job, so it is important that we can at least fix issues which cause it to fail. Otherwise it should just be removed from the build?

@kim-em kim-em added this pull request to the merge queue Apr 23, 2024
Merged via the queue into leanprover:master with commit 4f664fb Apr 23, 2024
11 checks passed
@digama0 digama0 deleted the deprecated_since branch April 23, 2024 19:34
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 24, 2024
- consistently use the YYYY-MM-DD format
- when easily possible, put the date on the same line as the `deprecated` attribute
- when easily possible, format the entire declaration on the same line

Why these changes?
- consistency makes it easier for tools to parse this information
- compactness: I don't see a good reason for these declarations taking up more space than needed;
 as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
@Kha
Copy link
Member

Kha commented Apr 24, 2024

My bad, I thought the line I quoted would clarify how I found it but I guess it's still pretty opaque. If you look at the failing log (which I can't see anymore because of the rebase), you will see that Nix store path I quoted mentioned. If you ignore the hash and file system parts, the relevant part is examples.ICERM2022.ctor.md - this is a mangled string of the "build step" (derivation) name that ultimately is derived from the output file name, examples/ICERM2022/ctor.md. Does that make sense? Why it's the deprecations specifically I have no idea but looking at the file and considering the PR at hand that was the only logical conclusion.

Otherwise it should just be removed from the build?

If it continues to be an issue, we should just downgrade these examples to basic non-interactive code blocks, yes. But this was the first (perplexing) failure in that part for a long while.

mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 24, 2024
Occasionally, remove a "deprecated by" or "deprecated since", to fit the line length.

This is desirable (to me) because
- it's more compact: I don't see a good reason for these declarations taking up more space than needed;
as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
@digama0
Copy link
Collaborator Author

digama0 commented Apr 24, 2024

Why it's the deprecations specifically I have no idea but looking at the file and considering the PR at hand that was the only logical conclusion.

Yes, I don't understand this either. It does appear that the deprecations are responsible, in the sense that removing the deprecated uses fixed the build, but the code here doesn't touch deprecation reporting at all, and that file contains no deprecated attributes. My best guess is that there are some stage0 shenanigans going on whereby the lean compiler is either reading a deprecation with the wrong syntax or reading an olean deprecation entry as the old type or vice versa, resulting in a failure of the deprecation linter to report errors correctly.

Jun2M pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 24, 2024
- consistently use the YYYY-MM-DD format
- when easily possible, put the date on the same line as the `deprecated` attribute
- when easily possible, format the entire declaration on the same line

Why these changes?
- consistency makes it easier for tools to parse this information
- compactness: I don't see a good reason for these declarations taking up more space than needed;
 as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
Jun2M pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 24, 2024
Occasionally, remove a "deprecated by" or "deprecated since", to fit the line length.

This is desirable (to me) because
- it's more compact: I don't see a good reason for these declarations taking up more space than needed;
as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
callesonne pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 16, 2024
- consistently use the YYYY-MM-DD format
- when easily possible, put the date on the same line as the `deprecated` attribute
- when easily possible, format the entire declaration on the same line

Why these changes?
- consistency makes it easier for tools to parse this information
- compactness: I don't see a good reason for these declarations taking up more space than needed;
 as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
callesonne pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 16, 2024
Occasionally, remove a "deprecated by" or "deprecated since", to fit the line length.

This is desirable (to me) because
- it's more compact: I don't see a good reason for these declarations taking up more space than needed;
as I understand it, deprecated lemmas are not supposed to be used in mathlib anyway
- putting the date on the same line as the attribute makes it easier to discover un-dated deprecations;
they also ease writing a tool to replace these by a machine-readable version using leanprover/lean4#3968
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Waiting for PR author to address issues 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.

5 participants