git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Deprecation warnings
commit6566dd4aba9bfef4257ad7c5ccaa20eccc195fb4 authorPhil Freeman <paf31@cantab.net> dateThu 4 Feb 2016, 21:22 (11 years ago) parentc9aac3c
2 files changed+29−1
src/Language/PureScript/Errors.hs+28−1 src/Language/PureScript/Linter.hs+1
src/Language/PureScript/Errors.hs+28−1
@@ -24,6 +24,7 @@ import Control.Arrow ((&&&))
2424import Language.PureScript.Crash
2525import Language.PureScript.AST
2626import Language.PureScript.Pretty
27+import Language.PureScript.Pretty.Common (before)
2728import Language.PureScript.Types
2829import Language.PureScript.Names
2930import Language.PureScript.Kinds
@@ -128,6 +129,7 @@ data SimpleErrorMessage
128129 | UnusedDctorImport (ProperName 'TypeName)
129130 | UnusedDctorExplicitImport (ProperName 'TypeName) [ProperName 'ConstructorName]
130131 | DeprecatedOperatorDecl String
132+ | DeprecatedOperatorSection Expr (Either Expr Expr)
131133 | DeprecatedQualifiedSyntax ModuleName ModuleName
132134 | DeprecatedClassImport ModuleName (ProperName 'ClassName)
133135 | DeprecatedClassExport (ProperName 'ClassName)
@@ -304,6 +306,7 @@ errorCode em = case unwrapErrorMessage em of
304306 UnusedDctorImport{} -> "UnusedDctorImport"
305307 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
306308 DeprecatedOperatorDecl{} -> "DeprecatedOperatorDecl"
309+ DeprecatedOperatorSection{} -> "DeprecatedOperatorSection"
307310 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
308311 DeprecatedClassImport{} -> "DeprecatedClassImport"
309312 DeprecatedClassExport{} -> "DeprecatedClassExport"
@@ -426,7 +429,7 @@ wikiUri e = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ error
426429-- TODO Other possible suggestions:
427430-- WildcardInferredType - source span not small enough
428431-- DuplicateSelectiveImport - would require 2 ranges to remove and 1 insert
429−-- DeprecatedClassExport, DeprecatedClassImport, would want to replace smaller span?
432+-- DeprecatedClassExport, DeprecatedClassImport, DeprecatedOperatorSection, would want to replace smaller span?
430433errorSuggestion :: SimpleErrorMessage -> Maybe ErrorSuggestion
431434errorSuggestion err = case err of
432435 UnusedImport{} -> emptySuggestion
@@ -854,6 +857,30 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
854857 , line "Support for value-declared operators will be removed in PureScript 0.9."
855858 ]
856859
860+ renderSimpleErrorMessage (DeprecatedOperatorSection op val) =
861+ paras [ line "An operator section uses legacy syntax. Operator sections are now written using anonymous function syntax:"
862+ , indent $ foldr1 before $
863+ case val of
864+ Left l ->
865+ [ line "("
866+ , prettyPrintValue valueDepth l
867+ , line " "
868+ , renderOperator op
869+ , line " _)"
870+ ]
871+ Right r ->
872+ [ line "(_ "
873+ , renderOperator op
874+ , line " "
875+ , prettyPrintValue valueDepth r
876+ , line ")"
877+ ]
878+ , line "Support for legacy operator sections will be removed in PureScript 0.9."
879+ ]
880+ where
881+ renderOperator (PositionedValue _ _ ex) = renderOperator ex
882+ renderOperator (Var (Qualified _ (Op ident))) = line ident
883+ renderOperator other = Box.hcat Box.top [ line "`", prettyPrintValue valueDepth other, line "`" ]
857884 renderSimpleErrorMessage (DeprecatedQualifiedSyntax name qualName) =
858885 paras [ line "Import uses the deprecated 'qualified' syntax:"
859886 , indent $ line $ "import qualified " ++ runModuleName name ++ " as " ++ runModuleName qualName
src/Language/PureScript/Linter.hs+1
@@ -71,6 +71,7 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
7171 go d | Just i <- getDeclIdent d
7272 , i `S.member` s = errorMessage (ShadowedName i)
7373 | otherwise = mempty
74+ stepE _ (OperatorSection op val) = errorMessage $ DeprecatedOperatorSection op val
7475 stepE _ _ = mempty
7576
7677 stepB :: S.Set Ident -> Binder -> MultipleErrors