Manually fuse elem and map in checkArrayValueUsedAsIndex

This commit is contained in:
Joseph C. Sible 2023-12-31 02:31:07 -05:00
parent 71c0fcb737
commit 6e5b5401c6
1 changed files with 2 additions and 1 deletions

View File

@ -4628,7 +4628,8 @@ checkArrayValueUsedAsIndex params _ =
-- Is this one of the 'for' arrays?
(loopWord, _) <- find ((==arrayName) . snd) arrays
-- Are we still in this loop?
guard $ getId loop `elem` NE.map getId (getPath parents t)
let loopId = getId loop
guard $ any (\t -> loopId == getId t) (getPath parents t)
return [
makeComment WarningC (getId loopWord) 2302 "This loops over values. To loop over keys, use \"${!array[@]}\".",
makeComment WarningC (getId arrayRef) 2303 $ (e4m name) ++ " is an array value, not a key. Use directly or loop over keys instead."