Skip to content

Commit

Permalink
more defensive coding: guard against a non-iterable loclist (#4912)
Browse files Browse the repository at this point in the history
Sometimes `s:HandleExit` can execute a deferred linter callback, which
ends up setting the `l:loclist` that's passed into
`ale#engine#HandleLoclist` at the end of `s:HandleExit` to a dictionary.
This dictionary cannot be iterated over, and thus errors out.

Guard against trying to iterate over values that don't make sense.

Co-authored-by: Alexander Huynh <[email protected]>
  • Loading branch information
ahrex and Alexander Huynh authored Mar 8, 2025
1 parent 7882fb9 commit a6db6c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autoload/ale/engine.vim
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ function! s:HandleExit(job_info, buffer, output, data) abort
let l:loclist = []
endtry

if type(l:loclist) isnot# v:t_list
" we only expect the list type; don't pass anything else down to
" `ale#engine#HandleLoclist` since it won't understand it
let l:loclist = []
endif

call ale#engine#HandleLoclist(l:linter.name, a:buffer, l:loclist, 0)
endfunction

Expand Down

0 comments on commit a6db6c9

Please sign in to comment.