Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find references for type members is empty #88

Closed
mscfd opened this issue Feb 27, 2019 · 5 comments
Closed

Find references for type members is empty #88

mscfd opened this issue Feb 27, 2019 · 5 comments

Comments

@mscfd
Copy link

mscfd commented Feb 27, 2019

For the code below (named test.f90), the following gives no results:
fortls --debug_rootpath . --debug_references --debug_filepath test.f90 --debug_line 5 --debug_char 18

The position is on bar, and this should give the call self%bar line, right?

module mod

type x
contains
   procedure :: bar
end type x

contains

subroutine bar(self, some_arg)
   class(x) :: self
   real :: some_arg
   call self%bar(some_arg)
end subroutine bar
end module mod
@hansec
Copy link
Owner

hansec commented Feb 27, 2019

Yes, this is intentional. Find references support for type members is not currently available as mentioned in the README. I plan to add this soon, it is pretty straightforward except for how to handle inheritance in a consistent and expected way.

@mscfd
Copy link
Author

mscfd commented Feb 27, 2019

Sorry, I have missed that, as I was not that interested in the animated gifs.

What is the problem with inheritance? For a type bound procedure sub of some type t, I would expect any invoking of x%sub() for x of some type s which extends t (in one or more steps). Then all types which extend t and override sub. Are there any other kind of references?

@hansec
Copy link
Owner

hansec commented Feb 27, 2019

Yeah, it's just a little more nuanced. Say you have the structure below. I agree with you that if I look for references to test_parent::foo then I should provide both obj1%foo() and obj2%foo() as results. However, if I instead look for references to foo in the line CALL obj2%foo() should it include references to foo in variables of the parent type as well (ie. test_parent::foo)? Personally, I don't think it should, since that is not the explicit object you are searching for. However, I am not 100% sure that would be the universally expected behavior. It isn't really an issue I just hadn't convinced myself of this fact yet. I will probably just go ahead and implement it this way though and then see if people reach for the pitchforks. It shouldn't be very involved.

MODULE test_mod
TYPE :: test_parent
CONTAINS
  PROCEDURE :: foo => parent_foo
END TYPE test_parent
!
TYPE,  EXTENDS(test_parent) :: test_child
CONTAINS
  PROCEDURE :: foo => child_foo
END TYPE test_child
END MODULE test_mod
!
PROGRAM test_prog
USE test_mod
IMPLICIT NONE
TYPE(test_parent) :: obj1
TYPE(test_child) :: obj2

CALL obj1%foo()
CALL obj2%foo()

END PROGRAM test_prog

@mscfd
Copy link
Author

mscfd commented Feb 27, 2019

Indeed test_parent::foo should not be mentioned. On the other hand, I guess one should be careful with type versus class. Lets say I look for foo from obj1, which I know to be of type (not of class) test_parent (cursor position at call obj1%foo()), then I can also exclude foo from test_child, as foo was overwritten. On the other hand, if obj1 is of class(test_parent) instead of type(test_parent), then I should include foo from test_child and hence the line call obj2%foo() should be among the listed references.

@hansec hansec closed this as completed in 98ad32e Feb 27, 2019
@mscfd
Copy link
Author

mscfd commented Feb 28, 2019

Great, works fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants