Skip to content

Commit

Permalink
Manually fuse elem and map in checkArrayValueUsedAsIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible committed Dec 31, 2023
1 parent 71c0fcb commit 6e5b540
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ShellCheck/Analytics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 6e5b540

Please sign in to comment.