When reparsing array indices, do it recursively
This commit is contained in:
parent
f1bdda54cb
commit
363c0633e0
src/ShellCheck
|
@ -2394,6 +2394,7 @@ prop_checkUnused47= verifyNotTree checkUnusedAssignments "a=1; alias hello='echo
|
|||
prop_checkUnused48= verifyNotTree checkUnusedAssignments "_a=1"
|
||||
prop_checkUnused49= verifyNotTree checkUnusedAssignments "declare -A array; key=a; [[ -v array[$key] ]]"
|
||||
prop_checkUnused50= verifyNotTree checkUnusedAssignments "foofunc() { :; }; typeset -fx foofunc"
|
||||
prop_checkUnused51= verifyTree checkUnusedAssignments "x[y[z=1]]=1; echo ${x[@]}"
|
||||
|
||||
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
|
||||
where
|
||||
|
|
|
@ -3463,9 +3463,9 @@ notesForContext list = zipWith ($) [first, second] $ filter isName list
|
|||
|
||||
-- Go over all T_UnparsedIndex and reparse them as either arithmetic or text
|
||||
-- depending on declare -A statements.
|
||||
reparseIndices root =
|
||||
analyze blank blank f root
|
||||
reparseIndices root = process root
|
||||
where
|
||||
process = analyze blank blank f
|
||||
associative = getAssociativeArrays root
|
||||
isAssociative s = s `elem` associative
|
||||
f (T_Assignment id mode name indices value) = do
|
||||
|
@ -3490,8 +3490,9 @@ reparseIndices root =
|
|||
|
||||
fixAssignmentIndex name word =
|
||||
case word of
|
||||
T_UnparsedIndex id pos src ->
|
||||
parsed name pos src
|
||||
T_UnparsedIndex id pos src -> do
|
||||
idx <- parsed name pos src
|
||||
process idx -- Recursively parse for cases like x[y[z=1]]=1
|
||||
_ -> return word
|
||||
|
||||
parsed name pos src =
|
||||
|
|
Loading…
Reference in New Issue