mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-11 02:02:54 +08:00
Recognize declare -A statements when value is inlined.
This commit is contained in:
@@ -262,6 +262,11 @@ getAssociativeArrays t =
|
|||||||
let flags = getAllFlags t
|
let flags = getAllFlags t
|
||||||
guard $ elem "A" $ map snd flags
|
guard $ elem "A" $ map snd flags
|
||||||
let args = map fst . filter ((==) "" . snd) $ flags
|
let args = map fst . filter ((==) "" . snd) $ flags
|
||||||
let names = mapMaybe getLiteralString args
|
let names = mapMaybe (getLiteralStringExt nameAssignments) args
|
||||||
return $ tell names
|
return $ tell names
|
||||||
f _ = return ()
|
f _ = return ()
|
||||||
|
|
||||||
|
nameAssignments t =
|
||||||
|
case t of
|
||||||
|
T_Assignment _ _ name _ _ -> return name
|
||||||
|
otherwise -> Nothing
|
||||||
|
@@ -2120,6 +2120,7 @@ prop_checkUnassignedReferences21= verifyTree checkUnassignedReferences "echo ${#
|
|||||||
prop_checkUnassignedReferences22= verifyNotTree checkUnassignedReferences "echo ${!os*}"
|
prop_checkUnassignedReferences22= verifyNotTree checkUnassignedReferences "echo ${!os*}"
|
||||||
prop_checkUnassignedReferences23= verifyTree checkUnassignedReferences "declare -a foo; foo[bar]=42;"
|
prop_checkUnassignedReferences23= verifyTree checkUnassignedReferences "declare -a foo; foo[bar]=42;"
|
||||||
prop_checkUnassignedReferences24= verifyNotTree checkUnassignedReferences "declare -A foo; foo[bar]=42;"
|
prop_checkUnassignedReferences24= verifyNotTree checkUnassignedReferences "declare -A foo; foo[bar]=42;"
|
||||||
|
prop_checkUnassignedReferences25= verifyNotTree checkUnassignedReferences "declare -A foo=(); foo[bar]=42;"
|
||||||
checkUnassignedReferences params t = warnings
|
checkUnassignedReferences params t = warnings
|
||||||
where
|
where
|
||||||
(readMap, writeMap) = execState (mapM tally $ variableFlow params) (Map.empty, Map.empty)
|
(readMap, writeMap) = execState (mapM tally $ variableFlow params) (Map.empty, Map.empty)
|
||||||
|
Reference in New Issue
Block a user