on master help sign in
Merge pull request #1195 from ziman/set-warnreach
ed0f118Edwin Brady
src/Idris/ASTUtils.hs+9
@@ -123,3 +123,12 @@ ist_callgraph n =
123-- some fields of the CGInfo record
123-- some fields of the CGInfo record
124cg_usedpos :: Field CGInfo [(Int, [UsageReason])]
124cg_usedpos :: Field CGInfo [(Int, [UsageReason])]
125cg_usedpos = Field usedpos (\v cg -> cg{ usedpos = v })
125cg_usedpos = Field usedpos (\v cg -> cg{ usedpos = v })
126+
127+
128+-- Commandline flags
129+--------------------
130+
131+opts_idrisCmdline :: Field IState [Opt]
132+opts_idrisCmdline =
133+ Field opt_cmdline (\v opts -> opts{ opt_cmdline = v })
134+ . Field idris_options (\v ist -> ist{ idris_options = v })
src/Idris/REPL.hs+11−5
@@ -4,6 +4,7 @@
4module Idris.REPL where
4module Idris.REPL where
5
5
6import Idris.AbsSyntax
6import Idris.AbsSyntax
7+import Idris.ASTUtils
7import Idris.Apropos (apropos)
8import Idris.Apropos (apropos)
8import Idris.REPLParser
9import Idris.REPLParser
9import Idris.ElabDecls
10import Idris.ElabDecls
@@ -1032,6 +1033,8 @@ process h fn (SetOpt AutoSolve) = setAutoSolve True
1032process h fn (UnsetOpt AutoSolve) = setAutoSolve False
1033process h fn (UnsetOpt AutoSolve) = setAutoSolve False
1033process h fn (SetOpt NoBanner) = setNoBanner True
1034process h fn (SetOpt NoBanner) = setNoBanner True
1034process h fn (UnsetOpt NoBanner) = setNoBanner False
1035process h fn (UnsetOpt NoBanner) = setNoBanner False
1036+process h fn (SetOpt WarnReach) = fmodifyState opts_idrisCmdline $ nub . (WarnReach:)
1037+process h fn (UnsetOpt WarnReach) = fmodifyState opts_idrisCmdline $ delete WarnReach
1035
1038
1036process h fn (SetOpt _) = iPrintError "Not a valid option"
1039process h fn (SetOpt _) = iPrintError "Not a valid option"
1037process h fn (UnsetOpt _) = iPrintError "Not a valid option"
1040process h fn (UnsetOpt _) = iPrintError "Not a valid option"
@@ -1255,7 +1258,13 @@ loadInputs h inputs
1255 _ -> return ()
1258 _ -> return ()
1256 ist <- getIState
1259 ist <- getIState
1257 putIState (ist { idris_tyinfodata = tidata,
1260 putIState (ist { idris_tyinfodata = tidata,
1258− idris_patdefs = patdefs }))
1261+ idris_patdefs = patdefs })
1262+
1263+ case opt getOutput opts of
1264+ [] -> performUsageAnalysis -- interactive
1265+ _ -> return [] -- batch, will be checked by the compiler
1266+
1267+ return ())
1259 (\e -> do i <- getIState
1268 (\e -> do i <- getIState
1260 case e of
1269 case e of
1261 At f e' -> do setErrSpan f
1270 At f e' -> do setErrSpan f
@@ -1399,10 +1408,7 @@ idrisMain opts =
1399
1408
1400 ok <- noErrors
1409 ok <- noErrors
1401 when ok $ case output of
1410 when ok $ case output of
1402− -- just do the checks
1411+ [] -> return ()
1403− [] -> performUsageAnalysis >> return ()
1404−
1405− -- the compiler will run usage analysis itself
1406 (o:_) -> idrisCatch (process stdout "" (Compile cgn o))
1412 (o:_) -> idrisCatch (process stdout "" (Compile cgn o))
1407 (\e -> do ist <- getIState ; iputStrLn $ pshow ist e)
1413 (\e -> do ist <- getIState ; iputStrLn $ pshow ist e)
1408
1414
src/Idris/REPLParser.hs+1
@@ -120,6 +120,7 @@ pOption = do discard (P.symbol "errorcontext"); return ErrContext
120 <|> do discard (P.symbol "originalerrors"); return ShowOrigErr
120 <|> do discard (P.symbol "originalerrors"); return ShowOrigErr
121 <|> do discard (P.symbol "autosolve"); return AutoSolve
121 <|> do discard (P.symbol "autosolve"); return AutoSolve
122 <|> do discard (P.symbol "nobanner") ; return NoBanner
122 <|> do discard (P.symbol "nobanner") ; return NoBanner
123+ <|> do discard (P.symbol "warnreach"); return WarnReach
123
124
124codegenOption :: P.IdrisParser Codegen
125codegenOption :: P.IdrisParser Codegen
125codegenOption = do discard (P.symbol "javascript"); return ViaJavaScript
126codegenOption = do discard (P.symbol "javascript"); return ViaJavaScript