Error while including a file

#1

Sometimes I get this error while including a file include("filename.jl"). Then I have to restart Julia and it works again. I am using Revise.
No a single line of the included file is executed.
What could be the problem? Thanks in advance.

ERROR: MethodError: no method matching getindex(::Array{UInt8,1}, ::UnitRange{UInt64})
Closest candidates are:
  getindex(::Array, ::Int64) at array.jl:729
  getindex(::Array, ::Int64, ::Int64, ::Int64...) at array.jl:730
  getindex(::Array, ::UnitRange{Int64}) at array.jl:734
  ...
Stacktrace:
 [1] pwd() at ./file.jl:54
 [2] abspath at ./path.jl:325 [inlined]
 [3] _include_dependency(::Module, ::String) at ./loading.jl:742
 [4] include_relative(::Module, ::String) at ./loading.jl:1030
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] include(::String) at ./client.jl:403
 [7] top-level scope at none:0

#2

It’s kinda odd because the method

  getindex(::Array, ::UnitRange{Int64}) at array.jl:734

that is suggested should match?

#3

The method it’s complaining is missing is

getindex(::Vector{UInt8}, ::UnitRange{UInt64})

note that the second argument is UInt64 not Int64.

1 Like
#4

Ah, good catch.

Even so:

julia> a = UInt8[1,2,3,4,5,6];

julia> a[1:UInt64(3)]
3-element Array{UInt8,1}:
 0x01
 0x02
 0x03

Perhaps Revise is deleting some method?

#5

It does seem as if the generic fallback method at abstractarray.jl:925 is gettind deleted.

It’s pretty strange that Revise could do that. I’m wondering if there should be some kind of check to make sure it does not delete methods from Base, perhaps unless some global flag is set.

#6

Please file as a Revise issue. Might be similar to https://github.com/timholy/Revise.jl/issues/234 (which is a Julia bug, not a Revise bug). Theoretically Revise shouldn’t do this, but it does depend on accurate subtyping. Or there could be a bug.

3 Likes
#7

@RaulDurand, to catch this in the act, turn on Revise’s logging. This is what I do in my startup.jl file:

 atreplinit() do repl
    try
        @eval using Revise
        @async Revise.debug_logger()
        @async Revise.wait_steal_repl_backend()
    catch
    end
end

Then if the error happens again, you can retrospectively examine rlogger = Revise.debug_logger() and figure out what happened. See instructions in those docs about how to capture info and submit a bug report.

3 Likes