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

TOML: Make Dates a type parameter #55017

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Jul 3, 2024

This will allow us to resolve the Dates at compile-time eventually. It also fixes TOML.Parser() to return Dates types again.

The plan is to land:

  1. This PR
  2. Use Base.TOML.Parser{Dates} for TOML parsing w/ Dates support Pkg.jl#3938
  3. TOML: Improve type-stability #55016

This is a breaking change for anyone who was using the internal Dates support downstream, but then again so was #54755

This allows the `Dates` calls to be statically inferred
This change also adds back the `.Dates` field, which negates the type
stability improvements for now but can be removed once we land a fix to
Pkg to use the new internal constructor.
This is another backwards compatibility concession to Pkg, which we'll
remove in the breaking follow-up PR.
@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 3, 2024

#54755 was only breaking if you accessed internals of TOML, but otherwise should be transparent to the consumer of public APIs

@topolarity
Copy link
Member Author

#54755 was only breaking if you accessed internals of TOML, but otherwise should be transparent to the consumer of public APIs

Doesn't the TOML parser no longer return Dates objects by default, unless you use the new DTParser constructor?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 3, 2024

I don't think that type was made public, or was the standard way to call into the package

@KristofferC
Copy link
Sponsor Member

I don't think that type was made public, or was the standard way to call into the package

TOML.Parser is public and it should parse dates so we have to fix that.

@KristofferC
Copy link
Sponsor Member

I see we backported #54755 so presumably we have to backport a fix for that...

return parser
end
# Dates-enabled constructors
Parser() = Parser{Dates}()
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Type piracy I guess. Maybe that's ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

I left a comment behind in base/toml_parser.jl specifically delegating this definition to the TOML stdlib, so I think this is fine.

@topolarity
Copy link
Member Author

I see we backported #54755 so presumably we have to backport a fix for that...

I think this change should be backportable for that

No type-stability improvements unless we back-port all three PR's, but the other two are optional to backport

@topolarity topolarity force-pushed the ct/toml-stable-dates branch 2 times, most recently from e057250 to 842f332 Compare July 4, 2024 21:29
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.

None yet

3 participants