-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
JuliaDebug/CodeTracking.jl
#129Description
I have a package with a function. The function works just fine, but when I tried to look inside with @descend, it gave me a weird error:
StringIndexError: invalid index [8], valid nearby indices [6]=>'′', [9]=>'#'
The function does use unicode (including the \prime at index 6) and is @generated, but I can't reproduce the error as an MWE with just those factors. In fact, I can't produce an MWE at all without using my package. I've also tried debugging the call to @descend, but it's quite slow. Admittedly the generated function does some weird stuff inside, but ultimately generates a very straightforward (though very long) Expr.
The MWE is
using Pkg
Pkg.activate(; temp=true)
Pkg.add(["Cthulhu", "PostNewtonian"])
using Cthulhu
using PostNewtonian
pnsystem = rand(BBH)
@descend binding_energy_deriv(pnsystem)The error is
julia> @descend binding_energy_deriv(rand(BBH))
𝓔′(pnsystem::PNSystem{ST, PNOrder}; pn_expansion_reducer) where {ST, PNOrder} @ PostNewtonian ~/.julia/packages/PostNewtonian/SMkI4/src/pn_expressions/binding_energy.jl:136
ERROR: StringIndexError: invalid index [8], valid nearby indices [6]=>'′', [9]=>'#'
Stacktrace:
[1] string_index_err(s::String, i::Int64)
@ Base ./strings/string.jl:12
[2] getindex
@ ./strings/string.jl:470 [inlined]
[3] strip_gensym(str::String)
@ CodeTracking ~/.julia/packages/CodeTracking/0lrn2/src/utils.jl:204
[4] strip_gensym
@ ~/.julia/packages/CodeTracking/0lrn2/src/utils.jl:199 [inlined]
[5] is_func_expr(ex::Any, meth::Method)
@ CodeTracking ~/.julia/packages/CodeTracking/0lrn2/src/utils.jl:121
[6] definition(::Type{String}, method::Method)
@ CodeTracking ~/.julia/packages/CodeTracking/0lrn2/src/CodeTracking.jl:263
[7] tsn_and_mappings(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any; warn::Bool, strip_macros::Bool, kwargs::@Kwargs{})
@ TypedSyntax ~/.julia/packages/TypedSyntax/cH1Nu/src/node.jl:34
[8] get_typed_sourcetext(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any; warn::Bool)
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/reflection.jl:361
[9] add_callsites!(d::Dict{…}, visited_mis::Set{…}, diagnostics::Vector{…}, mi::Core.MethodInstance, source_mi::Core.MethodInstance; optimize::Bool, annotate_source::Bool, interp::Cthulhu.CthulhuInterpreter)
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/codeview.jl:345
[10] add_callsites!(d::Dict{…}, visited_mis::Set{…}, diagnostics::Vector{…}, mi::Core.MethodInstance, source_mi::Core.MethodInstance; optimize::Bool, annotate_source::Bool, interp::Cthulhu.CthulhuInterpreter)
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/codeview.jl:337
[11] cthulhu_typed(io::IOContext{…}, debuginfo::Symbol, src::Core.CodeInfo, rt::Any, exct::Any, effects::Core.Compiler.Effects, mi::Core.MethodInstance; iswarn::Bool, hide_type_stable::Bool, optimize::Bool, pc2remarks::Nothing, pc2effects::Nothing, pc2excts::Nothing, inline_cost::Bool, type_annotations::Bool, annotate_source::Bool, inlay_types_vscode::Bool, diagnostics_vscode::Bool, jump_always::Bool, interp::Cthulhu.CthulhuInterpreter)
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/codeview.jl:160
[12] cthulhu_typed(::IOContext{…}, ::Cthulhu.DInfo.DebugInfo, ::Core.CodeInfo, ::Vararg{…}; kwargs::@Kwargs{…})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/codeview.jl:105
[13] (::Cthulhu.var"#92#99"{…})(lambda_io::IOContext{…})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:521
[14] stringify(f::Any, context::IOContext{Base.TTY})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/ui.jl:92
[15]
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:520
[16] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, mi::Core.MethodInstance; kwargs::@Kwargs{…})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:791
[17] _descend(term::REPL.Terminals.TTYTerminal, args::Any; interp::Core.Compiler.NativeInterpreter, kwargs::@Kwargs{…})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:807
[18] __descend_with_error_handling(args::Any; terminal::Any, kwargs...)
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:222
[19] _descend_with_error_handling(f::Any, argtypes::Any; kwargs::@Kwargs{iswarn::Bool})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:211
[20] descend_code_typed(::Any, ::Vararg{Any}; kwargs::@Kwargs{})
@ Cthulhu ~/.julia/packages/Cthulhu/8y2RA/src/Cthulhu.jl:169
[21] top-level scope
@ REPL[4]:1
My versioninfo is
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M2 Max
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
JULIA_EDITOR = code
And the Pkg.status is
[f68482b8] Cthulhu v2.12.7
[377afc40] PostNewtonian v0.9.1
Thanks for any help, and the excellent package!
Metadata
Metadata
Assignees
Labels
No labels