on master help sign in
#346, don't use nameModule, which raises errors (#356)

* #346, don't use nameModule, which raises errors * #346, ban nameModule, as its dangerous

commitc32217b02b75715d0233be30ca6a928c373ea8c4 authorNeil Mitchell <ndmitchell@gmail.com> dateSat 25 Jan 2020, 15:16 (7 years ago) parent1d32025
2 files changed+5−2
.hlint.yaml+3 src/Development/IDE/Spans/AtPoint.hs+2−2
.hlint.yaml+3
@@ -97,9 +97,12 @@
9797# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
9898#
9999- functions:
100+ # Things that are unsafe in Haskell base library
100101 - {name: unsafeInterleaveIO, within: []}
101102 - {name: unsafeDupablePerformIO, within: []}
102103 - {name: unsafeCoerce, within: []}
104+ # Things that are a bit dangerous in the GHC API
105+ - {name: nameModule, within: []}
103106
104107# Add custom hints for this project
105108#
src/Development/IDE/Spans/AtPoint.hs+2−2
@@ -133,7 +133,7 @@ locationsAtPoint getHieFile IdeOptions{..} pkgState pos =
133133 -- This case usually arises when the definition is in an external package.
134134 -- In this case the interface files contain garbage source spans
135135 -- so we instead read the .hie files to get useful source spans.
136− let mod = nameModule name
136+ mod <- MaybeT $ return $ nameModule_maybe name
137137 let unitId = moduleUnitId mod
138138 pkgConfig <- MaybeT $ pure $ lookupPackageConfig unitId pkgState
139139 hiePath <- MaybeT $ liftIO $ optLocateHieFile optPkgLocationOpts pkgConfig mod
@@ -147,7 +147,7 @@ locationsAtPoint getHieFile IdeOptions{..} pkgState pos =
147147 pure span
148148 -- We ignore uniques and source spans and only compare the name and the module.
149149 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'
151151 setFileName f (RealSrcSpan span) = RealSrcSpan (span { srcSpanFile = mkFastString f })
152152 setFileName _ span@(UnhelpfulSpan _) = span
153153