From d60b482a43b6073bc8f501ad667cb3c59a44b6ed Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Thu, 16 Jan 2025 21:54:35 +0100 Subject: [PATCH] remove unused iterator/operator --- src/Juvix/Compiler/Concrete/Language/Base.hs | 2 + .../FromParsed/Analysis/Scoping/Error.hs | 4 -- .../Analysis/Scoping/Error/Types.hs | 46 ------------------- test/Scope/Negative.hs | 10 ---- tests/negative/Iterators5.juvix | 10 ---- tests/negative/UnusedOperatorDef.juvix | 4 -- 6 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 tests/negative/Iterators5.juvix delete mode 100644 tests/negative/UnusedOperatorDef.juvix diff --git a/src/Juvix/Compiler/Concrete/Language/Base.hs b/src/Juvix/Compiler/Concrete/Language/Base.hs index 26c4079c0f..ebeaf735df 100644 --- a/src/Juvix/Compiler/Concrete/Language/Base.hs +++ b/src/Juvix/Compiler/Concrete/Language/Base.hs @@ -455,6 +455,7 @@ instance Serialize FixityDef instance NFData FixityDef -- TODO use stage in _opSymbol and _opFixity +-- TODO allow qualified names data OperatorSyntaxDef (s :: Stage) = OperatorSyntaxDef { _opSymbol :: SymbolType s, _opFixity :: Symbol, @@ -484,6 +485,7 @@ instance Serialize (OperatorSyntaxDef 'Scoped) instance NFData (OperatorSyntaxDef 'Scoped) +-- TODO allow qualified names data IteratorSyntaxDef (s :: Stage) = IteratorSyntaxDef { _iterSymbol :: SymbolType s, _iterInfo :: Maybe ParsedIteratorInfo, diff --git a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error.hs b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error.hs index 39b89433d9..cd51b8ba1d 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error.hs @@ -28,8 +28,6 @@ data ScoperError | ErrMultipleExport MultipleExportConflict | ErrAmbiguousSym AmbiguousSym | ErrAmbiguousModuleSym AmbiguousModuleSym - | ErrUnusedOperatorDef UnusedOperatorDef - | ErrUnusedIteratorDef UnusedIteratorDef | ErrDoubleBracesPattern DoubleBracesPattern | ErrDoubleBinderPattern DoubleBinderPattern | ErrAliasBinderPattern AliasBinderPattern @@ -80,8 +78,6 @@ instance ToGenericError ScoperError where ErrMultipleExport e -> genericError e ErrAmbiguousSym e -> genericError e ErrAmbiguousModuleSym e -> genericError e - ErrUnusedOperatorDef e -> genericError e - ErrUnusedIteratorDef e -> genericError e ErrDoubleBracesPattern e -> genericError e ErrDoubleBinderPattern e -> genericError e ErrAliasBinderPattern e -> genericError e diff --git a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error/Types.hs b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error/Types.hs index 100f5ce713..5fe8c06aab 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error/Types.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromParsed/Analysis/Scoping/Error/Types.hs @@ -424,52 +424,6 @@ instance ToGenericError ModuleNotInScope where i = getLoc (e ^. moduleNotInScopeName) msg = "The module" <+> ppCode opts' _moduleNotInScopeName <+> "is not in scope" -newtype UnusedOperatorDef = UnusedOperatorDef - { _unusedOperatorDef :: OperatorSyntaxDef 'Parsed - } - deriving stock (Show) - -instance ToGenericError UnusedOperatorDef where - genericError UnusedOperatorDef {..} = ask >>= generr - where - generr opts = - return - GenericError - { _genericErrorLoc = i, - _genericErrorMessage = prettyError msg, - _genericErrorIntervals = [i] - } - where - opts' = fromGenericOptions opts - i = getLoc _unusedOperatorDef - msg = - "Unused operator syntax definition:" - <> line - <> ppCode opts' _unusedOperatorDef - -newtype UnusedIteratorDef = UnusedIteratorDef - { _unusedIteratorDef :: IteratorSyntaxDef 'Parsed - } - deriving stock (Show) - -instance ToGenericError UnusedIteratorDef where - genericError UnusedIteratorDef {..} = ask >>= generr - where - generr opts = - return - GenericError - { _genericErrorLoc = i, - _genericErrorMessage = prettyError msg, - _genericErrorIntervals = [i] - } - where - opts' = fromGenericOptions opts - i = getLoc _unusedIteratorDef - msg = - "Unused iterator syntax definition:" - <> line - <> ppCode opts' _unusedIteratorDef - data AmbiguousSym = AmbiguousSym { _ambiguousSymName :: Name, _ambiguousSymEntires :: [PreSymbolEntry] diff --git a/test/Scope/Negative.hs b/test/Scope/Negative.hs index 4703377126..1a1e6bda39 100644 --- a/test/Scope/Negative.hs +++ b/test/Scope/Negative.hs @@ -109,11 +109,6 @@ scoperErrorTests = $(mkRelDir ".") $(mkRelFile "ModuleNotInScope.juvix") $ wantsError ErrModuleNotInScope, - negTest - "Unused operator syntax definition" - $(mkRelDir ".") - $(mkRelFile "UnusedOperatorDef.juvix") - $ wantsError ErrUnusedOperatorDef, negTest "Ambiguous symbol" $(mkRelDir ".") @@ -199,11 +194,6 @@ scoperErrorTests = $(mkRelDir ".") $(mkRelFile "Iterators4.juvix") $ wantsError ErrDuplicateIterator, - negTest - "Unused iterator declaration" - $(mkRelDir ".") - $(mkRelFile "Iterators5.juvix") - $ wantsError ErrUnusedIteratorDef, negTest "Repeated name in named application" $(mkRelDir ".") diff --git a/tests/negative/Iterators5.juvix b/tests/negative/Iterators5.juvix deleted file mode 100644 index 274f2e9e38..0000000000 --- a/tests/negative/Iterators5.juvix +++ /dev/null @@ -1,10 +0,0 @@ -module Iterators5; - -syntax iterator map; - -builtin bool -type Bool := - | true : Bool - | false : Bool; - -main : Bool := true; diff --git a/tests/negative/UnusedOperatorDef.juvix b/tests/negative/UnusedOperatorDef.juvix deleted file mode 100644 index f928d1faf0..0000000000 --- a/tests/negative/UnusedOperatorDef.juvix +++ /dev/null @@ -1,4 +0,0 @@ -module UnusedOperatorDef; - syntax fixity add := binary; - syntax operator + add; -end ;