Merge pull request #1298 from ngzhian/1268
Fix false positive when indexing into array in cond
This commit is contained in:
commit
c3ac4c3d87
|
@ -520,7 +520,7 @@ readConditionContents single =
|
|||
notFollowedBy2 (try (spacing >> string "]"))
|
||||
x <- readNormalWord
|
||||
pos <- getPosition
|
||||
when (endedWith "]" x) $ do
|
||||
when (endedWith "]" x && notArrayIndex x) $ do
|
||||
parseProblemAt pos ErrorC 1020 $
|
||||
"You need a space before the " ++ (if single then "]" else "]]") ++ "."
|
||||
fail "Missing space before ]"
|
||||
|
@ -534,6 +534,8 @@ readConditionContents single =
|
|||
case last s of T_Literal id s -> str `isSuffixOf` s
|
||||
_ -> False
|
||||
endedWith _ _ = False
|
||||
notArrayIndex (T_NormalWord id s@(_:T_Literal _ t:_)) = t /= "["
|
||||
notArrayIndex _ = True
|
||||
|
||||
readCondAndOp = readAndOrOp TC_And "&&" False <|> readAndOrOp TC_And "-a" True
|
||||
|
||||
|
|
Loading…
Reference in New Issue