Make it possible to deprecate constants#5582
Conversation
f8d3b32 to
f8b9a03
Compare
f8b9a03 to
db2337a
Compare
|
I marked |
|
I don't know how close we are to the next Typst release, and therefore how urgent this PR is, but I can decouple it from typst/codex#19 if necessary. |
|
Decoupling it would be nice in principle. I haven't yet commented here because the amount of changes seem quite large, but I haven't yet considered things enough to comment on whether that's unavoidable or whether it could be simplified. |
db2337a to
2d9f0c3
Compare
|
If that helps, in the first commit, the main changes are in |
|
Two thoughts:
|
I agree the accumulation of
I am not convinced this would be better. The advantage of Footnotes
|
2d9f0c3 to
42ec8b1
Compare
|
Should I deprecate |
|
Properly deprecating the methods that were deprecated in #5671 would likely require a new attribute for items in a |
|
I opened #5798 as an alternative, with the rationale for differing design decisions in the PR description. |
|
Closing in favor of #5798, which is more lightweight and has some other advantages. |
Overview
This PR adds the ability to deprecate constants from the standard library (i.e., no syntax is provided to enable the user to deprecate things). When a deprecated constant is used, a warning will be emitted. As of now, no constant is deprecated, so this cannot be observed.
The second commit bumps Codex to typst/codex#19, and retrieves deprecation info from Codex to mark deprecated symbols and modules as such in Typst. This PR is marked as a draft for now as it requires typst/codex#19 to be merged first.Undone by the last commit, as per #5582 (comment).Implementation details
I can think of three notable details:
I did not change the behavior of
crates/typst-ide, nordoc. In the future, we may want to use deprecation information in those crates.When importing a deprecated constant, no warning is emitted. Instead, a warning is emitted when the symbol is used. This is because emitting a warning when importing a deprecated constant does not make sense in the case of a wildcard import. Moreover, emitting a warning on import would likely result in duplicated warnings: one when the constant is imported, and another one when it is used.
When importing a value called
is, a warning used to be emitted aboutisbeing a future keyword. I removed it, because the same warning is already emitted at the place where the binding is defined.Testing
For now, I have not extensively tested this, but I will in the following days.I added two tests.