on master help sign in
#346, don't use nameModule, which raises errors (#356)
c32217bNeil Mitchell
.hlint.yaml+3
@@ -97,9 +97,12 @@
97# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
97# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
98#
98#
99- functions:
99- functions:
100+ # Things that are unsafe in Haskell base library
100 - {name: unsafeInterleaveIO, within: []}
101 - {name: unsafeInterleaveIO, within: []}
101 - {name: unsafeDupablePerformIO, within: []}
102 - {name: unsafeDupablePerformIO, within: []}
102 - {name: unsafeCoerce, within: []}
103 - {name: unsafeCoerce, within: []}
104+ # Things that are a bit dangerous in the GHC API
105+ - {name: nameModule, within: []}
103
106
104# Add custom hints for this project
107# Add custom hints for this project
105#
108#
src/Development/IDE/Spans/AtPoint.hs+2−2
@@ -133,7 +133,7 @@ locationsAtPoint getHieFile IdeOptions{..} pkgState pos =
133 -- This case usually arises when the definition is in an external package.
133 -- This case usually arises when the definition is in an external package.
134 -- In this case the interface files contain garbage source spans
134 -- In this case the interface files contain garbage source spans
135 -- so we instead read the .hie files to get useful source spans.
135 -- so we instead read the .hie files to get useful source spans.
136− let mod = nameModule name
136+ mod <- MaybeT $ return $ nameModule_maybe name
137 let unitId = moduleUnitId mod
137 let unitId = moduleUnitId mod
138 pkgConfig <- MaybeT $ pure $ lookupPackageConfig unitId pkgState
138 pkgConfig <- MaybeT $ pure $ lookupPackageConfig unitId pkgState
139 hiePath <- MaybeT $ liftIO $ optLocateHieFile optPkgLocationOpts pkgConfig mod
139 hiePath <- MaybeT $ liftIO $ optLocateHieFile optPkgLocationOpts pkgConfig mod
@@ -147,7 +147,7 @@ locationsAtPoint getHieFile IdeOptions{..} pkgState pos =
147 pure span
147 pure span
148 -- We ignore uniques and source spans and only compare the name and the module.
148 -- We ignore uniques and source spans and only compare the name and the module.
149 eqName :: Name -> Name -> Bool
149 eqName :: Name -> Name -> Bool
150− eqName n n' = nameOccName n == nameOccName n' && nameModule n == nameModule n'
150+ eqName n n' = nameOccName n == nameOccName n' && nameModule_maybe n == nameModule_maybe n'
151 setFileName f (RealSrcSpan span) = RealSrcSpan (span { srcSpanFile = mkFastString f })
151 setFileName f (RealSrcSpan span) = RealSrcSpan (span { srcSpanFile = mkFastString f })
152 setFileName _ span@(UnhelpfulSpan _) = span
152 setFileName _ span@(UnhelpfulSpan _) = span
153
153