Don't warn about repeated range in [[ -v arr[xxx] ]] (fixes #2285)

This commit is contained in:
Vidar Holen 2021-07-25 12:59:56 -07:00
parent 9eb63c97e6
commit 0d58337cdd
3 changed files with 16 additions and 4 deletions

View file

@ -737,7 +737,7 @@ getReferencedVariables parents t =
TC_Unary id _ "-v" token -> getIfReference t token
TC_Unary id _ "-R" token -> getIfReference t token
TC_Binary id DoubleBracket op lhs rhs ->
if isDereferencing op
if isDereferencingBinaryOp op
then concatMap (getIfReference t) [lhs, rhs]
else []
@ -771,12 +771,12 @@ getReferencedVariables parents t =
when (isDigit h) $ fail "is a number"
return (context, token, getBracedReference str)
isDereferencing = (`elem` ["-eq", "-ne", "-lt", "-le", "-gt", "-ge"])
isArithmeticAssignment t = case getPath parents t of
this: TA_Assignment _ "=" lhs _ :_ -> lhs == t
_ -> False
isDereferencingBinaryOp = (`elem` ["-eq", "-ne", "-lt", "-le", "-gt", "-ge"])
dataTypeFrom defaultType v = (case v of T_Array {} -> DataArray; _ -> defaultType) $ SourceFrom [v]