diff --git a/stdlib/TOML/src/print.jl b/stdlib/TOML/src/print.jl index 63f65b017d393..c6c046b9b40c6 100644 --- a/stdlib/TOML/src/print.jl +++ b/stdlib/TOML/src/print.jl @@ -77,7 +77,7 @@ end # Fallback function printvalue(f::MbyFunc, io::IO, value, sorted::Bool) toml_value = to_toml_value(f, value) - @invokelatest printvalue(f, io, toml_value) + @invokelatest printvalue(f, io, toml_value, sorted) end function printvalue(f::MbyFunc, io::IO, value::AbstractVector, sorted::Bool) @@ -156,7 +156,7 @@ function print_table(f::MbyFunc, io::IO, a::AbstractDict, ) if a in inline_tables - @invokelatest print_inline_table(f, io, a) + @invokelatest print_inline_table(f, io, a, sorted) return end diff --git a/stdlib/TOML/test/print.jl b/stdlib/TOML/test/print.jl index 8fba1b1c1df10..e8a6431cb34a7 100644 --- a/stdlib/TOML/test/print.jl +++ b/stdlib/TOML/test/print.jl @@ -94,6 +94,14 @@ loaders = ["gzip", { driver = "csv", args = {delim = "\t"}}] a = 222 d = 333 """ + + # https://github.com/JuliaLang/julia/pull/57584 + d = Dict("b" => [MyStruct(1), MyStruct(2)]) + @test toml_str(d) do x + x isa MyStruct && return Dict("a" => x.a) + end == """ + b = [{a = 1}, {a = 2}] + """ end @testset "unsigned integers" for (x, s) in [ @@ -196,6 +204,14 @@ LocalPkg = {path = "LocalPkg"} @test toml_str(d; sorted=true, inline_tables) == s @test roundtrip(s) + +# https://github.com/JuliaLang/julia/pull/57584 +d = Dict("a" => 1, "b" => 2) +inline_tables = IdSet{Dict}([d]) +s = "{a = 1, b = 2}" +@test toml_str(d; sorted=true, inline_tables) == s + + # multiline strings (#55083) s = """ a = \"\"\"lorem ipsum