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: print: handle mixed vector of dicts and non-dicts #47876

Merged
merged 4 commits into from
Dec 12, 2022

Conversation

fonsp
Copy link
Member

@fonsp fonsp commented Dec 12, 2022

Fix #45340

@fonsp fonsp requested a review from KristofferC December 12, 2022 14:37
@KristofferC
Copy link
Member

KristofferC commented Dec 12, 2022

All the tests added here pass for me (using Julia master). Ref JuliaLang/TOML.jl#40

@vtjnash
Copy link
Member

vtjnash commented Dec 12, 2022

So are you saying this was already fixed by JuliaLang/TOML.jl#40?

@KristofferC
Copy link
Member

At least to an extent. I don't know if this fixes some more issues than that, but the tests here are at least incomplete to show that.

@fonsp
Copy link
Member Author

fonsp commented Dec 12, 2022

For me, the tests fail locally if I undo my change to stdlib/TOML/src/print.jl. I also checked against the Julia 1.9.0-alpha1 binary from julialang.org, where the second test fails. (The PR you linked is included in 1.9.0-alpha1, right?)

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-alpha1 (2022-11-15)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> import TOML

julia> TOML.print(Dict("b" => Any[Dict("a" => 222, "d" => 333), 111]))
[[b]]
a = 222
d = 333
[[b]]
ERROR: array should contain only tables
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] print_table(f::Nothing, io::Base.TTY, a::Dict{String, Vector{Any}}, ks::Vector{String}; indent::Int64, first_block::Bool, sorted::Bool, by::Function)
   @ TOML.Internals.Printer ~/julia19/julia-1.9.0-alpha1/share/julia/stdlib/v1.9/TOML/src/print.jl:187
 [3] print_table (repeats 2 times)
   @ ~/julia19/julia-1.9.0-alpha1/share/julia/stdlib/v1.9/TOML/src/print.jl:128 [inlined]
 [4] #print#4
   @ ~/julia19/julia-1.9.0-alpha1/share/julia/stdlib/v1.9/TOML/src/print.jl:200 [inlined]
 [5] print(a::Dict{String, Vector{Any}}; sorted::Bool, by::Function)
   @ TOML.Internals.Printer ~/julia19/julia-1.9.0-alpha1/share/julia/stdlib/v1.9/TOML/src/print.jl:203
 [6] print(a::Dict{String, Vector{Any}})
   @ TOML.Internals.Printer ~/julia19/julia-1.9.0-alpha1/share/julia/stdlib/v1.9/TOML/src/print.jl:203
 [7] top-level scope
   @ REPL[2]:1

@KristofferC
Copy link
Member

I must have messed up something with the copy-pasting then, the first and last work now but the middle still fails on master.

@KristofferC KristofferC added the backport 1.9 Change should be backported to release-1.9 label Dec 12, 2022
@KristofferC KristofferC merged commit 4ff6288 into JuliaLang:master Dec 12, 2022
@fonsp fonsp deleted the patch-6 branch December 12, 2022 21:55
@fonsp
Copy link
Member Author

fonsp commented Dec 12, 2022

Thanks for the quick merge! Should I make the same PR to TOML.jl?

@KristofferC
Copy link
Member

Let's keep the development here. TOML.jl should probably be archived.

KristofferC pushed a commit that referenced this pull request Dec 14, 2022
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Dec 27, 2022
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.

TOML: Dict inside mixed vector produces invalid TOML
3 participants