Cthulhu.jl icon indicating copy to clipboard operation
Cthulhu.jl copied to clipboard

Incorrect printing of types with source code

Open Zentrik opened this issue 1 year ago • 0 comments

julia> @descend Base.print_to_string(Float64)
print_to_string(xs...) in Base at strings/io.jl:133
133 function print_to_string(xs::Tuple{DataType}...)::String
134     if isempty(xs::Tuple{DataType})::Bool
135         return ""
136     end
137     (siz::Int::Type{Int64})::Int64 = 0
138     for x::Type{Float64} in xs::Tuple{DataType}::Tuple{DataType, Int64}
139         (siz::Int64 += _str_sizehint(x::Type{Float64})::Int64)::Int64
140     ::Int64end
141     # specialized for performance reasons
142     s::IOBuffer = IOBuffer::Type{IOBuffer}(sizehint=siz::Int64::Tuple{Int64})::Core.var"#Type##kw"
143     for x::Type{Float64} in xs::Tuple{DataType}::Tuple{DataType, Int64}
144         print(s::IOBuffer, x::Type{Float64})
145     end
146     String::Type{String}(resize!(s::IOBuffer.data::Vector{UInt8}, s::IOBuffer.size::Int64)::Vector{UInt8})::String
147 end
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
 • 134 isempty(xs::Tuple{DataType})
   %7 = < concrete eval > convert(::Core.Const(Int64),::Core.Const(0))::Core.Const(0)
   138  x::Type{Float64} in xs::Tuple{DataType}
   139 _str_sizehint(x::Type{Float64})
   139 siz::Int64 += _str_sizehint(x::Type{Float64})::Int64
   138 \n139         (siz::Int64 += _str_sizehint(x::Type{Float64})::Int64)::Int64\n140 
   %22 = < constprop > iterate(::Core.Const((Float64,)),::Core.Const(2))::Core.Const(nothing)
   142 IOBuffer(sizehint=siz)
   142 IOBuffer::Type{IOBuffer}(sizehint=siz::Int64::Tuple{Int64})
v  142 s

On line 140 the ::Int64 is wrong. The 138 \n139 (siz::Int64 += _str_sizehint(x::Type{Float64})::Int64)::Int64\n140 seems wrong as well

Zentrik avatar Jun 19 '23 00:06 Zentrik