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: Avoid type-pirating Base.TOML.Parser #55892

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Sep 26, 2024

Since stdlibs can be duplicated but Base never is, Base.require_stdlib makes type piracy even more complicated than it normally would be.

To adapt, this changes TOML.Parser to be a type defined by the TOML stdlib, so that we can define methods on it without committing type-piracy and avoid problems like Pkg.jl#4017

Resolves JuliaLang/Pkg.jl#4017 (comment)

@topolarity topolarity added the backport 1.11 Change should be backported to release-1.11 label Sep 26, 2024
@nsajko nsajko added the TOML label Sep 26, 2024
@topolarity
Copy link
Member Author

topolarity commented Sep 26, 2024

As the failing build shows already, this is unfortunately going to break downstream packages that have been relying on Base.TOML.Parser === TOML.Parser

edit: I added some additional overloads that will hopefully smooth things over

@topolarity topolarity force-pushed the ct/no-toml-parser-piracy branch 3 times, most recently from b2baf00 to 0fb3fca Compare September 27, 2024 03:26
Copy link
Sponsor Member

@KristofferC KristofferC left a comment

Choose a reason for hiding this comment

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

Seems a lot better, thanks!

@topolarity
Copy link
Member Author

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@KristofferC KristofferC mentioned this pull request Sep 30, 2024
39 tasks
@KristofferC
Copy link
Sponsor Member

@nanosoldier runtests(["LinearRationalExpectations", "KissMCMC", "BlockArrays", "FiniteDiff", "BinaryBuilderAuditor", "UnivariateUnimodalHighestDensityRegion", "OptimalControl", "Polynomials4ML", "LSODA", "StippleCharts", "DECAES", "OrdinaryDiffEqFeagin", "OrdinaryDiffEqSSPRK", "OrdinaryDiffEqLowOrderRK", "GenieAuthorisation", "AztecDiamonds", "DynamicalSystemsBase", "DiffEqFinancial", "MathML", "EMpht", "JumpProblemLibrary", "PotentialFlow", "LiquidElectrolytes", "ActiveInference", "FaultTolerantControl", "GeneralizedSasakiNakamura", "FSimPlots", "TulipaPlots"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@KristofferC
Copy link
Sponsor Member

I don't understand why but the

Failed to precompile ExponentialFamily [62312e5e-252a-4322-ace9-a5f4bf9b357b] to "/home/pkgeval/.julia/compiled/v1.12/ExponentialFamily/jl_1aEV91".
Internal error: during type inference of
docm(LineNumberNode, Module, Any, Any)
Encountered unexpected error in runtime:
AssertionError(msg="irinterp is unable to handle heavy recursion")
collect_limitations! at ./compiler/ssair/irinterp.jl:4 [inlined]
from_interprocedural! at ./compiler/abstractinterpretation.jl:403 [inlined]
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:222
abstract_call_known at ./compiler/abstractinterpretation.jl:2358
abstract_call at ./compiler/abstractinterpretation.jl:2448
abstract_call at ./compiler/abstractinterpretation.jl:2441
abstract_call at ./compiler/ssair/irinterp.jl:54
abstract_eval_call at ./compiler/abstractinterpretation.jl:2608
abstract_eval_statement_expr at ./compiler/abstractinterpretation.jl:2843
reprocess_instruction! at ./compiler/ssair/irinterp.jl:146
#394 at ./compiler/ssair/irinterp.jl:342
scan! at ./compiler/ssair/irinterp.jl:264
....

looks consistent.

Since stdlibs can be duplicated but Base never is, `require_stdlib`
makes type piracy even more complicated than it normally would be.

To adapt, this changes `TOML.Parser` to be type defined by the TOML
stdlib, so that we can define methods on it without committing
type-piracy and avoid problems like Pkg.jl#4017
Despite being internal, these interfaces are used in a number of places
downstream, so it's best for TOML's parser type to have their interface
defined.
@topolarity
Copy link
Member Author

That's probably from #55843, which seems to be triggered more often with #55754 (and was recently reverted.)

I just rebased, so let's see if it's any better.

@topolarity
Copy link
Member Author

@nanosoldier runtests(["LinearRationalExpectations", "KissMCMC", "BlockArrays", "FiniteDiff", "BinaryBuilderAuditor", "UnivariateUnimodalHighestDensityRegion", "OptimalControl", "Polynomials4ML", "LSODA", "StippleCharts", "DECAES", "OrdinaryDiffEqFeagin", "OrdinaryDiffEqSSPRK", "OrdinaryDiffEqLowOrderRK", "GenieAuthorisation", "AztecDiamonds", "DynamicalSystemsBase", "DiffEqFinancial", "MathML", "EMpht", "JumpProblemLibrary", "PotentialFlow", "LiquidElectrolytes", "ActiveInference", "FaultTolerantControl", "GeneralizedSasakiNakamura", "FSimPlots", "TulipaPlots"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@topolarity
Copy link
Member Author

That looks much better

@topolarity topolarity added the merge me PR is reviewed. Merge when all tests are passing label Sep 30, 2024
@topolarity topolarity merged commit 2a2878c into JuliaLang:master Sep 30, 2024
9 checks passed
@topolarity topolarity removed the merge me PR is reviewed. Merge when all tests are passing label Sep 30, 2024
KristofferC pushed a commit that referenced this pull request Oct 1, 2024
Since stdlibs can be duplicated but Base never is, `Base.require_stdlib`
makes type piracy even more complicated than it normally would be.

To adapt, this changes `TOML.Parser` to be a type defined by the TOML
stdlib, so that we can define methods on it without committing
type-piracy and avoid problems like Pkg.jl#4017

Resolves
JuliaLang/Pkg.jl#4017 (comment)

(cherry picked from commit 2a2878c)
KristofferC added a commit that referenced this pull request Oct 1, 2024
Backported PRs:
- [x] #55849 <!-- Mmap: fix grow! for non file IOs -->
- [x] #55863 <!-- Update TaskLocalRNG docstring according to #49110 -->
- [x] #54433 <!-- Root globals in toplevel exprs -->
- [x] #55828 <!-- Fix some corner cases of `isapprox` with unsigned
integers -->
- [x] #55890 <!-- Profile: fix order of fields in heapsnapshot & improve
formatting -->
- [x] #55884 <!-- inference: add missing `TypeVar` handling for
`instanceof_tfunc` -->
- [x] #55881 <!-- Install terminfo data under /usr/share/julia -->
- [x] #55909 <!-- do not intentionally suppress errors in precompile
script from being reported or failing the result -->
- [x] #55355 <!-- relocation: account for trailing path separator in
depot paths -->
- [x] #55917 <!-- fix rawbigints OOB issues -->
- [x] #55892 <!-- TOML: Avoid type-pirating `Base.TOML.Parser` -->
- [x] #55798 <!-- Broadcast binary ops involving strided triangular -->
- [x] #55919 <!-- Limit `@inbounds` to indexing in the dual-iterator
branch in `copyto_unaliased!` -->

Contains multiple commits, manual intervention needed:
- [ ] #54009 <!-- allow extensions to trigger from packages in [deps]
-->
- [ ] #55509 <!-- Fix cong implementation to be properly random and not
just cycling. -->
- [ ] #55569 <!-- Add a docs section about loading/precomp/ttfx time
tuning -->
- [ ] #55824 <!-- Replace regex package module checks with actual code
checks -->

Non-merged PRs with backport label:
- [ ] #55932 <!-- REPL: make UndefVarError aware of imported modules -->
- [ ] #55910 <!-- Prevent extensions from blocking parallel
pre-compilation -->
- [ ] #55908 <!-- add logic to prefer loading modules that are already
loaded -->
- [ ] #55886 <!-- irrationals: restrict assume effects annotations to
known types -->
- [ ] #55871 <!-- lowering: don't reverse handler order in
`(pop-handler-list ...)` -->
- [ ] #55870 <!-- fix infinite recursion in `promote_type` for
`Irrational` -->
- [ ] #55867 <!-- update `hash` doc string: `widen` not required any
more -->
- [ ] #55851 <!-- [REPL] Fix #55850 by using `safe_realpath` instead of
`abspath` in `projname` -->
- [ ] #55813 <!-- Check for conflicting `@ccallable` name before JIT
registration -->
- [ ] #55743 <!-- doc: heap snapshot viewing -->
- [ ] #55741 <!-- Change annotations to use a NamedTuple -->
- [ ] #55534 <!-- Set stdlib sources as read-only during installation
-->
- [ ] #55499 <!-- propagate the terminal's `displaysize` to the
`IOContext` used by the REPL -->
- [ ] #55458 <!-- Allow for generically extracting unannotated string
-->
- [ ] #55457 <!-- Make AnnotateChar equality consider annotations -->
- [ ] #55220 <!-- `isfile_casesensitive` fixes on Windows -->
- [ ] #55169 <!-- `propertynames` for SVD respects private argument -->
- [ ] #54457 <!-- Make `String(::Memory)` copy -->
- [ ] #53957 <!-- tweak how filtering is done for what packages should
be precompiled -->
- [ ] #51479 <!-- prevent code loading from lookin in the versioned
environment when building Julia -->
- [ ] #50813 <!-- More doctests for Sockets and capitalization fix -->
- [ ] #50157 <!-- improve docs for `@inbounds` and
`Base.@propagate_inbounds` -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11 TOML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg> st fails second time around with ERROR: MethodError: no method matching Int64(::Dates.DateTime)
4 participants