mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-20 13:23:55 -07:00
Merge branch 'Flu-add-bang-to-function-chars'
This commit is contained in:
commit
6c1542a0e3
1 changed files with 11 additions and 5 deletions
|
@ -67,10 +67,14 @@ singleQuote = char '\''
|
|||
doubleQuote = char '"'
|
||||
variableStart = upper <|> lower <|> oneOf "_"
|
||||
variableChars = upper <|> lower <|> digit <|> oneOf "_"
|
||||
-- Chars to allow in function names
|
||||
functionChars = variableChars <|> oneOf ":+?-./^@,"
|
||||
-- Chars to allow function names to start with
|
||||
functionStartChars = variableChars <|> oneOf ":+?-./^@,"
|
||||
-- Chars to allow inside function names
|
||||
functionChars = variableChars <|> oneOf "#:+?-./^@,"
|
||||
-- Chars to allow function names to start with, using the 'function' keyword
|
||||
extendedFunctionStartChars = functionStartChars <|> oneOf "[]*=!"
|
||||
-- Chars to allow in functions using the 'function' keyword
|
||||
extendedFunctionChars = functionChars <|> oneOf "[]*=!"
|
||||
extendedFunctionChars = extendedFunctionStartChars <|> oneOf "[]*=!"
|
||||
specialVariable = oneOf (concat specialVariables)
|
||||
paramSubSpecialChars = oneOf "/:+-=%"
|
||||
quotableChars = "|&;<>()\\ '\t\n\r\xA0" ++ doubleQuotableChars
|
||||
|
@ -2755,6 +2759,8 @@ prop_readFunctionDefinition10 = isOk readFunctionDefinition "function foo () { t
|
|||
prop_readFunctionDefinition11 = isWarning readFunctionDefinition "function foo{\ntrue\n}"
|
||||
prop_readFunctionDefinition12 = isOk readFunctionDefinition "function []!() { true; }"
|
||||
prop_readFunctionDefinition13 = isOk readFunctionDefinition "@require(){ true; }"
|
||||
prop_readFunctionDefinition14 = isOk readFunctionDefinition "foo#bar(){ :; }"
|
||||
prop_readFunctionDefinition15 = isNotOk readFunctionDefinition "#bar(){ :; }"
|
||||
readFunctionDefinition = called "function" $ do
|
||||
start <- startSpan
|
||||
functionSignature <- try readFunctionSignature
|
||||
|
@ -2772,7 +2778,7 @@ readFunctionDefinition = called "function" $ do
|
|||
string "function"
|
||||
whitespace
|
||||
spacing
|
||||
name <- many1 extendedFunctionChars
|
||||
name <- (:) <$> extendedFunctionStartChars <*> many extendedFunctionChars
|
||||
spaces <- spacing
|
||||
hasParens <- wasIncluded readParens
|
||||
when (not hasParens && null spaces) $
|
||||
|
@ -2781,7 +2787,7 @@ readFunctionDefinition = called "function" $ do
|
|||
return $ \id -> T_Function id (FunctionKeyword True) (FunctionParentheses hasParens) name
|
||||
|
||||
readWithoutFunction = try $ do
|
||||
name <- many1 functionChars
|
||||
name <- (:) <$> functionStartChars <*> many functionChars
|
||||
guard $ name /= "time" -- Interferes with time ( foo )
|
||||
spacing
|
||||
readParens
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue