JuliaDebug / Cthulhu.jl

The slow descent into madness
MIT License
657 stars 41 forks source link

`Warning: couldn't retrieve source of` function #513

Closed dafred94 closed 2 months ago

dafred94 commented 1 year ago

software versions

MWE

When I enter this example code

using Revise
using Cthulhu
using ProfileView

function foo()
    T = rand() > 0.5 ? Int64 : Float64
    sum(rand(T, 100))
end

@descend foo()

, I see the following:

foo() @ Main c:\Users\Fred\git_managed\myFile.jl:656
┌ Warning: couldn't retrieve source of foo() @ Main c:\Users\Fred\git_managed\myFile.jl:656
└ @ TypedSyntax C:\Users\Fred\.julia\packages\TypedSyntax\LVzdW\src\node.jl:36
Variables
  #self#::Core.Const(foo)
  T::Union{Type{Float64}, Type{Int64}}
  @_3::Union{Type{Float64}, Type{Int64}}

∘ ─ %0 = invoke foo()::Union{Float64, Int64}
    @ c:\Users\Fred\git_managed\myFile.jl:657 within `foo`
1 ─       Core.NewvarNode(:(T))::Any
│   %2  = Main.rand()::Float64
│   %3  = (%2 > 0.5)::Bool
└──       goto #3 if not %3
2 ─       (@_3 = Main.Int64)::Core.Const(Int64)
└──       goto #4
3 ─       (@_3 = Main.Float64)::Core.Const(Float64)
4 ┄       (T = @_3)::Union{Type{Float64}, Type{Int64}}
│   @ c:\Users\Fred\git_managed\myFile.jl:658 within `foo`
│   %9  = Main.rand(T, 100)::Union{Vector{Float64}, Vector{Int64}}
│   %10 = Main.sum(%9)::Union{Float64, Int64}
└──       return %10
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, [j]ump to source always, [v]scode: inlay types, [V]scode: diagnostics.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
 • %2 = rand()::Float64
   %3 = >(::Float64,::Float64)::Bool
   %9 = call → rand(::Union{Type{Float64}, Type{Int64}},::Int64)::Union{Vector{Float64}, Vector{Int64}}
   %10 = call → sum(::Union{Vector{Float64}, Vector{Int64}})::Union{Float64, Int64}
   ↩

Can I do something so that I see... well the source code instead?

timholy commented 3 months ago

Works for me on both Windows and Linux.

simeonschaub commented 2 months ago

I am going to close this for now, please reopen if it's still an issue on 1.10