diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index f61f08d3b..7f72c14cd 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -307,7 +307,7 @@ methodCall = makeTerm' <$> symbol MethodCall <*> children (require <|> load <|> nameExpression = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expression call :: Assignment -call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (expressions <|> args)) +call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (args <|> expressions)) where args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expressions diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index f6e84513f..60df96e4d 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -53,6 +53,7 @@ arguments = info (version <*> helper <*> ((,) <$> optionsParser <*> argumentsPar <*> pure False -- PrintSource <*> pure Log.logfmtFormatter -- Formatter <*> pure 0 -- ProcessID + <*> switch (long "fail-on-warning" <> help "Fail on assignment warnings.") argumentsParser = (. Task.writeToOutput) . (>>=) <$> hsubparser (diffCommand <> parseCommand) <*> ( Right <$> strOption (long "output" <> short 'o' <> help "Output path, defaults to stdout") diff --git a/src/Semantic/Log.hs b/src/Semantic/Log.hs index 55c934de0..f472c0ad6 100644 --- a/src/Semantic/Log.hs +++ b/src/Semantic/Log.hs @@ -83,13 +83,14 @@ terminalFormatter Options{..} (Message level message pairs time) = -- | Options controlling logging, error handling, &c. data Options = Options - { optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors). - , optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging. - , optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems. - , optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime). - , optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime). - , optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime). - , optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime). + { optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors). + , optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging. + , optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems. + , optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime). + , optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime). + , optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime). + , optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime). + , optionsFailOnWarning :: Bool } defaultOptions :: Options @@ -101,6 +102,7 @@ defaultOptions = Options , optionsPrintSource = False , optionsFormatter = logfmtFormatter , optionsProcessID = 0 + , optionsFailOnWarning = False } configureOptionsForHandle :: MonadIO io => Handle -> Options -> io Options diff --git a/src/Semantic/Task.hs b/src/Semantic/Task.hs index 8ccf979a8..e4287c4d0 100644 --- a/src/Semantic/Task.hs +++ b/src/Semantic/Task.hs @@ -51,6 +51,7 @@ import Analysis.Decorator (decoratorWithAlgebra) import qualified Assigning.Assignment as Assignment import qualified Control.Abstract.Analysis as Analysis import qualified Control.Exception as Exc +import Control.Monad import Control.Monad.Effect.Exception import Control.Monad.Effect.Internal as Eff hiding (run) import Control.Monad.Effect.Reader @@ -215,6 +216,7 @@ runParser blob@Blob{..} parser = case parser of _ -> do writeStat (Stat.increment "parse.assign_warnings" languageTag) logError options Warning blob err (("task", "assign") : blobFields) + when (optionsFailOnWarning options) $ throwError (toException err) writeStat (Stat.count "parse.nodes" (length term) languageTag) pure term MarkdownParser ->