Skip to content

Commit

Permalink
while loop -> for loop in _simplify_include_frames (fixes #41566) (#4…
Browse files Browse the repository at this point in the history
…1622)

* while loop -> for loop in _simplify_include_frames (fixes #41566)

prevents the possibility of a bounds error when i = 0

(cherry picked from commit ed4f316)
  • Loading branch information
fredcallaway authored and KristofferC committed Jul 26, 2021
1 parent ac16744 commit aa9827f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,9 @@ end
# For improved user experience, filter out frames for include() implementation
# - see #33065. See also #35371 for extended discussion of internal frames.
function _simplify_include_frames(trace)
i = length(trace)
kept_frames = trues(i)
kept_frames = trues(length(trace))
first_ignored = nothing
while i >= 1
for i in length(trace):-1:1
frame::StackFrame, _ = trace[i]
mod = parentmodule(frame)
if first_ignored === nothing
Expand All @@ -813,10 +812,9 @@ function _simplify_include_frames(trace)
first_ignored = nothing
end
end
i -= 1
end
if first_ignored !== nothing
kept_frames[i:first_ignored] .= false
kept_frames[1:first_ignored] .= false
end
return trace[kept_frames]
end
Expand Down

0 comments on commit aa9827f

Please sign in to comment.