bosu / hscope

Other
22 stars 6 forks source link

Can't identify uses of symbol if explicit module name added? #14

Open phlummox opened 4 years ago

phlummox commented 4 years ago

I am trying hscope and have hit a stumbling block. I might be doing something wrong, but, by way of a minimal example, I write the following three modules:

---------------------
--- file Foo.hs --
module Foo
    where
someFunc :: IO ()
someFunc = putStrLn "someFunc"

---------------------
-- file UsesFoo.hs --
module UsesFoo
    where

import qualified Foo as F

myFunc = F.someFunc

----------------------
-- file UsesFoo2.hs --

module UsesFoo2
    where

import Foo as F

myFunc = someFunc

So, there are 2 modules that call someFunc, but one calls it as F.someFunc.

I build an hscope database with (adding "-v" to see exactly what's happening):

$ hscope -v -b src/UsesFoo.hs src/Foo.hs src/UsesFoo2.hs
Processing src/UsesFoo.hs
Processing src/Foo.hs
Processing src/UsesFoo2.hs

I query what functions call "someFunc":

$ hscope --callers=someFunc

What I'd expect is for the references to both UsesFoo and UsesFoo2 to show up. Re-naming modules on import (import Foo as F) in Haskell is ubiqitous, barely a program exists that doesn't do this.

Yet the result I get only shows UsesFoo2:

$ hscope --callers=someFunc
cscope: 2 lines
src/Foo.hs someFunc 2     ( someFunc
src/UsesFoo2.hs someFunc 6 myFunc = someFunc

Am I doing something wrong, or is this the expected behaviour? Given how common it is in Haskell to call functions with an explicit module name (possibly re-named), this seems like a bit of a drawback to using hscope in practice if it can't handle this situation.

bosu commented 4 years ago

Hi,

Am I doing something wrong, or is this the expected behaviour? Given how common it is in Haskell to call functions with an explicit module name (possibly re-named), this seems like a bit of a drawback to using hscope in practice if it can't handle this situation.

There is a very good change that you've found bug here.

As you have probably noticed, I do not do much work on hscope anymore and have no time to investigate right now.

Will be happy to merge patches though :)

phlummox commented 4 years ago

Ah, no worries. I'll submit a patch if I work out a fix - but mostly I was just experimenting to see if hscope would be a good addition to my Vim environment.

phlummox commented 4 years ago

I suppose most people these days are using plugins for ghcide for this, but I didn't have much luck getting ghcide working for me.