Improve message for SC2163 (export $var). Helps #1117
This commit is contained in:
parent
017af8333f
commit
7aa3a7ffc3
|
@ -587,13 +587,18 @@ checkSetAssignment = CommandCheck (Exactly "set") (f . arguments)
|
||||||
prop_checkExportedExpansions1 = verify checkExportedExpansions "export $foo"
|
prop_checkExportedExpansions1 = verify checkExportedExpansions "export $foo"
|
||||||
prop_checkExportedExpansions2 = verify checkExportedExpansions "export \"$foo\""
|
prop_checkExportedExpansions2 = verify checkExportedExpansions "export \"$foo\""
|
||||||
prop_checkExportedExpansions3 = verifyNot checkExportedExpansions "export foo"
|
prop_checkExportedExpansions3 = verifyNot checkExportedExpansions "export foo"
|
||||||
|
prop_checkExportedExpansions4 = verifyNot checkExportedExpansions "export ${foo?}"
|
||||||
checkExportedExpansions = CommandCheck (Exactly "export") (check . arguments)
|
checkExportedExpansions = CommandCheck (Exactly "export") (check . arguments)
|
||||||
where
|
where
|
||||||
check = mapM_ checkForVariables
|
check = mapM_ checkForVariables
|
||||||
checkForVariables f =
|
checkForVariables f =
|
||||||
case getWordParts f of
|
case getWordParts f of
|
||||||
[t@(T_DollarBraced {})] ->
|
[t@(T_DollarBraced {})] -> potentially $ do
|
||||||
warn (getId t) 2163 "Exporting an expansion rather than a variable."
|
let contents = bracedString t
|
||||||
|
let name = getBracedReference contents
|
||||||
|
guard $ name == contents
|
||||||
|
return . warn (getId t) 2163 $
|
||||||
|
"This does not export '" ++ name ++ "'. Remove $/${} for that, or use ${var?} to quiet."
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue