Skip to content

Commit 0037139

Browse files
lgoettgensfieker
authored andcommitted
Fix is_loaded_directly on nightly (#2141)
1 parent 42b9934 commit 0037139

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/utils.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ function is_loaded_directly()
2929
# inside of the _require_search_from_serialized function.
3030
# To make it a bit more robust, we check the difference between the line number of the beginning
3131
# of _require_search_from_serialized and the call to _include_from_serialized.
32-
bt = Base.process_backtrace(Base.backtrace())
33-
@debug "is_loaded_directly: full backtrace:\n$(sprint(show, "text/plain", bt))"
34-
Base.filter!(sf -> contains(string(sf[1].func), "_require_search_from_serialized"), bt)
35-
length_bt = length(bt)
36-
@debug "is_loaded_directly: `_require_search_from_serialized` appears $(length_bt) times in backtrace; expected 1"
37-
bt_entry = only(bt)[1]
38-
line_call = bt_entry.line
39-
line_funcbegin = bt_entry.linfo.def.line
32+
st = Base.stacktrace(Base.backtrace())
33+
@debug "is_loaded_directly: full backtrace:\n$(sprint(show, "text/plain", st))"
34+
Base.filter!(sf -> contains(string(sf.func), "_require_search_from_serialized") && !startswith(string(sf), "kwcall("), st)
35+
length_st = length(st)
36+
@debug "is_loaded_directly: `_require_search_from_serialized` appears $(length_st) times in backtrace; expected 1"
37+
sf = only(st)
38+
line_call = sf.line
39+
line_funcbegin = sf.linfo.def.line
4040
line_difference = line_call - line_funcbegin
4141
@debug "is_loaded_directly: `_require_search_from_serialized` called at line $line_call, function begins at line $line_funcbegin, difference $(line_difference)"
4242
# difference for `using Package` / `using OtherPackage`

0 commit comments

Comments
 (0)