Skip to content

internal error when trying to annotate_source #124

@vtjnash

Description

@vtjnash

When doing some code revising (resulting in line numbers being shifted or the wrong file being parsed), it seems that CodeTracking can run off the end of the file and crash:
https://github.com/timholy/CodeTracking.jl/blob/eb9d4016bfc2547df0561b06dd74e2b4468adadf/src/CodeTracking.jl#L252

shell> cd test

julia> descend(Base.structdiff, Tuple{NamedTuple, NamedTuple})                                                                                                                                                                                                                                                                        
ERROR: MethodError: no method matching +(::Nothing, ::Int64)                                                                                                       
                                                                                                                                                                   
Closest candidates are:                                                          
  +(::Any, ::Any, !Matched::Any, !Matched::Any...)                                                                                                                                                                                                                                                                                    
   @ Base operators.jl:587                                                                                                                                         
  +(!Matched::Base.CoreLogging.LogLevel, ::Integer)                                                                                                                
   @ Base logging.jl:131                                                                                                                                           
  +(!Matched::BigInt, ::Union{Int16, Int32, Int64, Int8})                                                                                                          
   @ Base gmp.jl:555                                                                                                                                               
  ...                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                      
Stacktrace:                                                                                                                                                                                                                                                                                                                           
  [1] definition(::Type{String}, method::Method)                                 
    @ CodeTracking ~/.julia/packages/CodeTracking/8vwW2/src/CodeTracking.jl:252                                                                                                                                                                                                                                                       
  [2] tsn_and_mappings(m::Method, src::Core.CodeInfo, rt::Any; warn::Bool, strip_macros::Bool, kwargs::@Kwargs{})                                                                                                                                                                                                                     
    @ TypedSyntax ~/.julia/dev/Cthulhu/TypedSyntax/src/node.jl:34                                                                                                  
  [3] get_typed_sourcetext(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any; warn::Bool)                                                                       
    @ Cthulhu ~/.julia/dev/Cthulhu/src/reflection.jl:354                                                                                                                                                                                                                                                                              
  [4] find_callsites(interp::Cthulhu.CthulhuInterpreter, CI::Core.CodeInfo, stmt_infos::Vector{Core.Compiler.CallInfo}, mi::Core.MethodInstance, slottypes::Vector{Any}, optimize::Bool, annotate_source::Bool)                                                                                                                       
    @ Cthulhu ~/.julia/dev/Cthulhu/src/reflection.jl:36                                                                                                            
  [5]                                                                                                                                                                                                                                                                                                                                 
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:465                                                                                                                                                                                                                                                                                 
  [6] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, mi::Core.MethodInstance; kwargs::@Kwargs{iswarn::Bool})                                                                                                                                                                                          
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:739                                                                                                              
  [7] _descend(term::REPL.Terminals.TTYTerminal, args::Any; interp::Core.Compiler.NativeInterpreter, kwargs::@Kwargs{iswarn::Bool})                                                                                                                                                                                                   
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:755                                                                                                              
  [8] __descend_with_error_handling(args::Any; terminal::Any, kwargs...)                                                                                           
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:211                                                                                                              
  [9] _descend_with_error_handling(f::Any, argtypes::Any; kwargs::@Kwargs{iswarn::Bool})
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:200
 [10] descend_code_typed(::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Cthulhu ~/.julia/dev/Cthulhu/src/Cthulhu.jl:158
 [11] top-level scope
    @ REPL[2]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions