on master help sign in
Merge pull request #2926 from ahmadsalim/warning/staticchange

Reenabled '[static]' with a deprecation warning

commitc4c7802c3f47647be0e952c1476826cd7bce272a authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateThu 28 Jan 2016, 21:36 (11 years ago) parentb0df543fb81dc3
4 files changed+17−20
src/Idris/ParseData.hs+1−5 src/Idris/ParseExpr.hs+5−5 src/Idris/ParseHelpers.hs+9−1 src/Idris/Parser.hs+2−9
src/Idris/ParseData.hs+1−5
@@ -167,11 +167,7 @@ dataOpts opts
167167 <|> return opts
168168 <?> "data options"
169169 where warnElim fc =
170− do ist <- get
171− let cmdline = opt_cmdline (idris_options ist)
172− unless (NoElimDeprecationWarnings `elem` cmdline) $
173− put ist { parserWarnings =
174− (fc, Msg "Eliminator generation is deprecated. Use an eliminator generator in a library instead.") : parserWarnings ist }
170+ parserWarning fc (Just NoElimDeprecationWarnings) (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
175171
176172{- | Parses a data type declaration
177173Data ::= DocComment? Accessibility? DataI DefaultEliminator FnName TypeSig ExplicitTypeDataRest?
src/Idris/ParseExpr.hs+5−5
@@ -333,11 +333,7 @@ caseOption syn = do lhs <- expr (syn { inPattern = True })
333333
334334warnTacticDeprecation :: FC -> IdrisParser ()
335335warnTacticDeprecation fc =
336− do ist <- get
337− let cmdline = opt_cmdline (idris_options ist)
338− unless (NoOldTacticDeprecationWarnings `elem` cmdline) $
339− put ist { parserWarnings =
340− (fc, Msg "This style of tactic proof is deprecated. See %runElab for the replacement.") : parserWarnings ist }
336+ parserWarning fc (Just NoOldTacticDeprecationWarnings) (Msg "This style of tactic proof is deprecated. See %runElab for the replacement.")
341337
342338{- | Parses a proof block
343339@
@@ -1390,6 +1386,10 @@ Static ::=
13901386-}
13911387static :: IdrisParser Static
13921388static = do reserved "%static"; return Static
1389+ <|> do reserved "[static]"
1390+ fc <- getFC
1391+ parserWarning fc Nothing (Msg "The use of [static] is deprecated, use %static instead.")
1392+ return Static
13931393 <|> return Dynamic
13941394 <?> "static modifier"
13951395
src/Idris/ParseHelpers.hs+9−1
@@ -7,7 +7,7 @@ module Idris.ParseHelpers where
77import Prelude hiding (pi)
88
99import Text.Trifecta.Delta
10−import Text.Trifecta hiding (span, stringLiteral, charLiteral, natural, symbol, char, string, whiteSpace)
10+import Text.Trifecta hiding (span, stringLiteral, charLiteral, natural, symbol, char, string, whiteSpace, Err)
1111import Text.Parser.LookAhead
1212import Text.Parser.Expression
1313import qualified Text.Parser.Token as Tok
@@ -105,6 +105,14 @@ reportParserWarnings = do ist <- getIState
105105 parserWarnings ist)
106106 clearParserWarnings
107107
108+
109+parserWarning :: FC -> Maybe Opt -> Err -> IdrisParser ()
110+parserWarning fc warnOpt warnErr = do
111+ ist <- get
112+ let cmdline = opt_cmdline (idris_options ist)
113+ unless (maybe False (`elem` cmdline) warnOpt) $
114+ put ist { parserWarnings = (fc, warnErr) : parserWarnings ist }
115+
108116{- * Space, comments and literals (token/lexing like parsers) -}
109117
110118-- | Consumes any simple whitespace (any character which satisfies Char.isSpace)
src/Idris/Parser.hs+2−9
@@ -878,10 +878,7 @@ class_ syn = do (doc, argDocs, acc)
878878 classKeyword = reservedHL "interface"
879879 <|> do reservedHL "class"
880880 fc <- getFC
881− ist <- get
882− put ist { parserWarnings =
883− (fc, Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
884− : parserWarnings ist }
881+ parserWarning fc Nothing (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
885882
886883 carg :: IdrisParser (Name, FC, PTerm)
887884 carg = do lchar '('; (i, ifc) <- name; lchar ':'; ty <- expr syn; lchar ')'
@@ -928,11 +925,7 @@ instance_ kwopt syn
928925 instanceKeyword = reservedHL "implementation"
929926 <|> do reservedHL "instance"
930927 fc <- getFC
931− ist <- get
932− put ist { parserWarnings =
933− (fc, Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
934− : parserWarnings ist }
935−
928+ parserWarning fc Nothing (Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
936929
937930-- | Parse a docstring
938931docstring :: SyntaxInfo