mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Make sure that goto on a subscript colon doesn't crash
This commit is contained in:
@@ -72,6 +72,10 @@ def infer_call_of_leaf(context, leaf, cut_own_trailer=False):
|
|||||||
# different trailers: `( x )`, `[ x ]` and `.x`. In the first two examples
|
# different trailers: `( x )`, `[ x ]` and `.x`. In the first two examples
|
||||||
# we should not match anything more than x.
|
# we should not match anything more than x.
|
||||||
if trailer.type != 'trailer' or leaf not in (trailer.children[0], trailer.children[-1]):
|
if trailer.type != 'trailer' or leaf not in (trailer.children[0], trailer.children[-1]):
|
||||||
|
if leaf == ':':
|
||||||
|
# Basically happens with foo[:] when the cursor is on the colon
|
||||||
|
from jedi.inference.base_value import NO_VALUES
|
||||||
|
return NO_VALUES
|
||||||
if trailer.type == 'atom':
|
if trailer.type == 'atom':
|
||||||
return context.infer_node(trailer)
|
return context.infer_node(trailer)
|
||||||
return context.infer_node(leaf)
|
return context.infer_node(leaf)
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ b[int():]
|
|||||||
#? list()
|
#? list()
|
||||||
b[:]
|
b[:]
|
||||||
|
|
||||||
|
#? 3
|
||||||
|
b[:]
|
||||||
|
|
||||||
#? int()
|
#? int()
|
||||||
b[:, 1]
|
b[:, 1]
|
||||||
#? int()
|
#? int()
|
||||||
|
|||||||
Reference in New Issue
Block a user