goto should always goto definitions, fixes #1304

This commit is contained in:
Dave Halter
2019-06-24 01:25:26 +02:00
parent 56ec79d62a
commit ebdae87821
2 changed files with 6 additions and 5 deletions

View File

@@ -318,11 +318,11 @@ class Evaluator(object):
return [TreeNameDefinition(context, name)]
elif type_ == 'param':
return [ParamName(context, name)]
elif type_ in ('funcdef', 'classdef'):
return [TreeNameDefinition(context, name)]
elif type_ in ('import_from', 'import_name'):
module_names = imports.infer_import(context, name, is_goto=True)
return module_names
else:
return [TreeNameDefinition(context, name)]
else:
contexts = self._follow_error_node_imports_if_possible(context, name)
if contexts is not None:

View File

@@ -203,9 +203,10 @@ for key, value in [(1,2)]:
#! ['for key, value in [(1,2)]: key']
key
for i in []:
#! ['for i in []: i']
i
#! 4 ['for y in [1]: y']
for y in [1]:
#! ['for y in [1]: y']
y
# -----------------
# decorator