on master help sign in
Merge pull request #2926 from ahmadsalim/warning/staticchange
c4c7802Jan de Muijnck-Hughes
src/Idris/ParseData.hs+1−5
@@ -167,11 +167,7 @@ dataOpts opts
167 <|> return opts
167 <|> return opts
168 <?> "data options"
168 <?> "data options"
169 where warnElim fc =
169 where warnElim fc =
170− do ist <- get
170+ parserWarning fc (Just NoElimDeprecationWarnings) (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
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 }
175
171
176{- | Parses a data type declaration
172{- | Parses a data type declaration
177Data ::= DocComment? Accessibility? DataI DefaultEliminator FnName TypeSig ExplicitTypeDataRest?
173Data ::= 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 })
333
333
334warnTacticDeprecation :: FC -> IdrisParser ()
334warnTacticDeprecation :: FC -> IdrisParser ()
335warnTacticDeprecation fc =
335warnTacticDeprecation 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.")
341
337
342{- | Parses a proof block
338{- | Parses a proof block
343@
339@
@@ -1390,6 +1386,10 @@ Static ::=
1390-}
1386-}
1391static :: IdrisParser Static
1387static :: IdrisParser Static
1392static = do reserved "%static"; return Static
1388static = 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
1393 <|> return Dynamic
1393 <|> return Dynamic
1394 <?> "static modifier"
1394 <?> "static modifier"
1395
1395
src/Idris/ParseHelpers.hs+9−1
@@ -7,7 +7,7 @@ module Idris.ParseHelpers where
7import Prelude hiding (pi)
7import Prelude hiding (pi)
8
8
9import Text.Trifecta.Delta
9import 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)
11import Text.Parser.LookAhead
11import Text.Parser.LookAhead
12import Text.Parser.Expression
12import Text.Parser.Expression
13import qualified Text.Parser.Token as Tok
13import qualified Text.Parser.Token as Tok
@@ -105,6 +105,14 @@ reportParserWarnings = do ist <- getIState
105 parserWarnings ist)
105 parserWarnings ist)
106 clearParserWarnings
106 clearParserWarnings
107
107
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+
108{- * Space, comments and literals (token/lexing like parsers) -}
116{- * Space, comments and literals (token/lexing like parsers) -}
109
117
110-- | Consumes any simple whitespace (any character which satisfies Char.isSpace)
118-- | 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)
878 classKeyword = reservedHL "interface"
878 classKeyword = reservedHL "interface"
879 <|> do reservedHL "class"
879 <|> do reservedHL "class"
880 fc <- getFC
880 fc <- getFC
881− ist <- get
882− put ist { parserWarnings =
883− (fc, Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
881+ parserWarning fc Nothing (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
884− : parserWarnings ist }
885
882
886 carg :: IdrisParser (Name, FC, PTerm)
883 carg :: IdrisParser (Name, FC, PTerm)
887 carg = do lchar '('; (i, ifc) <- name; lchar ':'; ty <- expr syn; lchar ')'
884 carg = do lchar '('; (i, ifc) <- name; lchar ':'; ty <- expr syn; lchar ')'
@@ -928,11 +925,7 @@ instance_ kwopt syn
928 instanceKeyword = reservedHL "implementation"
925 instanceKeyword = reservedHL "implementation"
929 <|> do reservedHL "instance"
926 <|> do reservedHL "instance"
930 fc <- getFC
927 fc <- getFC
931− ist <- get
932− put ist { parserWarnings =
933− (fc, Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
928+ parserWarning fc Nothing (Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
934− : parserWarnings ist }
935−
936
929
937-- | Parse a docstring
930-- | Parse a docstring
938docstring :: SyntaxInfo
931docstring :: SyntaxInfo