-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
avoid some invalidations from untyped dict code in TOML print #48908
Conversation
@@ -171,7 +171,8 @@ function print_table(f::MbyFunc, io::IO, a::AbstractDict, | |||
end | |||
if is_table(value) | |||
push!(ks, String(key)) | |||
header = isempty(value) || !all(is_tabular(v) for v in values(value))::Bool | |||
_values = @invokelatest values(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels semantically wrong to me
_values = @invokelatest values(value) | ||
header = isempty(value) || !all(is_tabular(v) for v in _values)::Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be:
header = isempty(value) || !(all(is_tabular(v) for v in @invokelatest values(value))::Bool)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::Bool
seems to be applied to the result of all
even as is, so nvm:
julia> code_typed((Any,); optimize=false) do value
_values = @invokelatest values(value)
header = isempty(value) || !all(is_tabular(v) for v in _values)::Bool
header
end
1-element Vector{Any}:
CodeInfo(
1 ─ Core.NewvarNode(:(#52))::Any
│ Core.NewvarNode(:(header))::Any
│ (_values = Base.invokelatest(Main.values, value))::Any
│ %4 = Main.isempty(value)::Any
└── goto #3 if not %4
2 ─ (@_6 = %4)::Any
└── goto #4
3 ─ (#52 = %new(Main.:(var"#52#54")))::Core.Const(var"#52#54"())
│ %9 = #52::Core.Const(var"#52#54"())
│ %10 = Base.Generator(%9, _values)::Base.Generator{_A, var"#52#54"} where _A
│ %11 = Main.all(%10)::Union{Missing, Bool}
│ %12 = Core.typeassert(%11, Main.Bool)::Bool
└── (@_6 = !%12)::Bool
4 ┄ (header = @_6)::Any
└── return header
) => Any
(cherry picked from commit 015301a)
(cherry picked from commit 015301a)
No description provided.