@@ -165,9 +165,13 @@ def find_in_scope(
165
165
obj_tree : dict ,
166
166
interface : bool = False ,
167
167
local_only : bool = False ,
168
+ var_line_number : int = None ,
168
169
):
169
170
def check_scope (
170
- local_scope : fortran_scope , var_name_lower : str , filter_public : bool = False
171
+ local_scope : fortran_scope ,
172
+ var_name_lower : str ,
173
+ filter_public : bool = False ,
174
+ var_line_number : int = None ,
171
175
):
172
176
for child in local_scope .get_children ():
173
177
if child .name .startswith ("#GEN_INT" ):
@@ -178,6 +182,19 @@ def check_scope(
178
182
if (child .vis < 0 ) or ((local_scope .def_vis < 0 ) and (child .vis <= 0 )):
179
183
continue
180
184
if child .name .lower () == var_name_lower :
185
+ # For functions with an implicit result() variable the name
186
+ # of the function is used. If we are hovering over the function
187
+ # definition, we do not want the implicit result() to be returned.
188
+ # If scope is from a function and child's name is same as functions name
189
+ # and start of scope i.e. function definition is equal to the request ln
190
+ # then we are need to skip this child
191
+ if (
192
+ isinstance (local_scope , fortran_function )
193
+ and local_scope .name .lower () == child .name .lower ()
194
+ and local_scope .sline == var_line_number
195
+ ):
196
+ return None
197
+
181
198
return child
182
199
return None
183
200
@@ -186,7 +203,7 @@ def check_scope(
186
203
# Check local scope
187
204
if scope is None :
188
205
return None
189
- tmp_var = check_scope (scope , var_name_lower )
206
+ tmp_var = check_scope (scope , var_name_lower , var_line_number = var_line_number )
190
207
if local_only or (tmp_var is not None ):
191
208
return tmp_var
192
209
# Check INCLUDE statements
0 commit comments