-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviordisplay and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.
Description
Minimal example:
mapvalues(f, nt::NamedTuple) =
NamedTuple{keys(nt)}(f(v) for v in values(nt))
nt = (a=1,b=2)
julia> @code_warntype mapvalues(identity, a)
MethodInstance for mapvalues(::typeof(identity), ::@NamedTuple{a::Int64, b::Int64})
from mapvalues(f, nt::NamedTuple) @ Main REPL[12]:1
Arguments
#self#::Core.Const(Main.mapvalues)
f::Core.Const(identity)
nt::@NamedTuple{a::Int64, b::Int64}
Locals
#1::var"#mapvalues##0#mapvalues##1"{typeof(identity)}
BodyERROR: BoundsError: attempt to access Core.SimpleVector at index [2]
Stacktrace:
[1] getindex
@ ./essentials.jl:935 [inlined]
[2] show_at_namedtuple(io::IOContext{IOBuffer}, syms::Tuple{Symbol, Symbol}, types::DataType)
@ Base ./show.jl:1229
[3] show_datatype(io::IOContext{IOBuffer}, x::DataType, wheres::Vector{TypeVar})
@ Base ./show.jl:1205
[4] _show_type(io::IOBuffer, x::Type)
@ Base ./show.jl:1010
[5] show(io::IOBuffer, x::Type)
@ Base ./show.jl:968
[6] print(io::IOBuffer, x::Type)
@ Base ./strings/io.jl:35
[7] print_to_string(::String, ::Type)
@ Base ./strings/io.jl:151
[8] string(::String, ::Type, ::Vararg{Any})
@ Base ./strings/io.jl:193
[9] warntype_type_printer(io::IOContext{Base.TTY}; type::Any, used::Bool, show_type::Bool, ::@Kwargs{})
@ InteractiveUtils ~/.julia/juliaup/julia-1.12.0+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/codeview.jl:32
[10] print_warntype_codeinfo(io::Base.TTY, src::Core.CodeInfo, rettype::Any, nargs::Int64; lineprinter::Base.Compiler.IRShow.var"#42#43", label_dynamic_calls::Bool)
@ InteractiveUtils ~/.julia/juliaup/julia-1.12.0+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/codeview.jl:75
[11] code_warntype(io::Base.TTY, f::Any, tt::Any; world::UInt64, interp::Compiler.NativeInterpreter, debuginfo::Symbol, optimize::Bool, kwargs::@Kwargs{})
@ InteractiveUtils ~/.julia/juliaup/julia-1.12.0+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/codeview.jl:171
[12] code_warntype(io::Base.TTY, f::Any, tt::Any)
@ InteractiveUtils ~/.julia/juliaup/julia-1.12.0+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/codeview.jl:146
[13] code_warntype(::Any, ::Vararg{Any}; kwargs...)
@ InteractiveUtils ~/.julia/juliaup/julia-1.12.0+0.x64.linux.gnu/share/julia/stdlib/v1.12/InteractiveUtils/src/codeview.jl:179
[14] top-level scope
@ REPL[16]:1
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviordisplay and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.