git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix detection of single open import
commit3c8b32e7ef1ed9e1ca3fb046f71064c1a801baa4 authorGary Burgess <gary.burgess@gmail.com> dateMon 29 Feb 2016, 16:58 (11 years ago) parent3732373
1 file changed+7−6
src/Language/PureScript/Linter/Imports.hs+7−6
src/Language/PureScript/Linter/Imports.hs+7−6
@@ -79,8 +79,8 @@ lintImports (Module _ _ mn mdecls mexports) env usedImps = do
7979
8080 let scope = maybe nullImports (\(_, imps, _) -> imps) (M.lookup mn env)
8181 usedImps' = foldr (elaborateUsed scope) usedImps exportedModules
82− numImplicitImports = getSum $ foldMap (Sum . countImplicitImports) mdecls
83− allowImplicit = numImplicitImports == 1
82+ numOpenImports = getSum $ foldMap (Sum . countOpenImports) mdecls
83+ allowImplicit = numOpenImports == 1
8484
8585 imps <- M.toAscList <$> findImports mdecls
8686
@@ -106,10 +106,11 @@ lintImports (Module _ _ mn mdecls mexports) env usedImps = do
106106
107107 where
108108
109− countImplicitImports :: Declaration -> Int
110− countImplicitImports (ImportDeclaration mn' Implicit _ _) | not (isPrim mn') = 1
111− countImplicitImports (PositionedDeclaration _ _ d) = countImplicitImports d
112− countImplicitImports _ = 0
109+ countOpenImports :: Declaration -> Int
110+ countOpenImports (ImportDeclaration mn' Implicit Nothing _) | not (isPrim mn') = 1
111+ countOpenImports (ImportDeclaration mn' (Hiding _) Nothing _) | not (isPrim mn') = 1
112+ countOpenImports (PositionedDeclaration _ _ d) = countOpenImports d
113+ countOpenImports _ = 0
113114
114115 -- Checks whether a module is the Prim module - used to suppress any checks
115116 -- made, as Prim is always implicitly imported.