From a6db6c95a6f71b2614698a04db5c6ddb68a10b72 Mon Sep 17 00:00:00 2001 From: Alexander Huynh Date: Sat, 8 Mar 2025 02:44:43 -0500 Subject: [PATCH] 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 --- autoload/ale/engine.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 7e337191..28579056 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -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