diff --git a/src/Weeder.hs b/src/Weeder.hs index c653ccc..7f4d39a 100644 --- a/src/Weeder.hs +++ b/src/Weeder.hs @@ -460,9 +460,9 @@ topLevelAnalysis n@Node{ nodeChildren } = do [ -- analyseStandaloneDeriving n -- , - analyseBinding n + analyseBinding n -- , analyseRewriteRule n - -- , analyseInstanceDeclaration n + , analyseInstanceDeclaration n -- , analyseClassDeclaration n -- , analyseDataDeclaration n ] diff --git a/tests/Main.hs b/tests/Main.hs index a1b5c53..60070f7 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -108,27 +108,32 @@ fileToTestCase sourceFilePath = analysis = execState ( analyseHieFile hieFile ) emptyAnalysis + testModule = + Module + ( DefiniteUnitId ( DefUnitId ( stringToInstalledUnitId "main" ) ) ) + testModuleName + reachableSet = reachable analysis ( Set.singleton Declaration { declModule = - Module - ( DefiniteUnitId ( DefUnitId ( stringToInstalledUnitId "main" ) ) ) - testModuleName + testModule , declOccName = mkOccName varName "root" } ) dead = - allDeclarations analysis Set.\\ reachableSet + Set.filter + ( \d -> declModule d == testModule ) + ( allDeclarations analysis Set.\\ reachableSet ) unless ( Set.null dead ) ( for_ dead \d -> - liftIO ( putStrLn ( declarationStableName d <> " is dead, but should be alive" ) ) + liftIO ( fail ( declarationStableName d <> " is dead, but should be alive" ) ) ) -- | Recursively search for .hie files in given directory diff --git a/tests/test-cases/Instances retain top level bindings.hs b/tests/test-cases/Instances retain top level bindings.hs new file mode 100644 index 0000000..3e8126e --- /dev/null +++ b/tests/test-cases/Instances retain top level bindings.hs @@ -0,0 +1,9 @@ +module Test () where + +alive :: String +alive = "Alive" + +data T = T + +instance Show T where + show T = alive