more defensive coding: guard against a non-iterable loclist (#4912)

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 <git@e.sc>
This commit is contained in:
Alexander Huynh
2025-03-08 02:44:43 -05:00
committed by GitHub
parent 7882fb9811
commit a6db6c95a6

View File

@@ -178,6 +178,12 @@ function! s:HandleExit(job_info, buffer, output, data) abort
let l:loclist = [] let l:loclist = []
endtry 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) call ale#engine#HandleLoclist(l:linter.name, a:buffer, l:loclist, 0)
endfunction endfunction