From 8478ad7ffb03a04a306f9312ca9b4427a1e2919b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 29 Nov 2019 17:10:07 +0100 Subject: [PATCH] Make sure that goto on a subscript colon doesn't crash --- jedi/inference/helpers.py | 4 ++++ test/completion/arrays.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/jedi/inference/helpers.py b/jedi/inference/helpers.py index b0e892e6..2dffba4b 100644 --- a/jedi/inference/helpers.py +++ b/jedi/inference/helpers.py @@ -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 # we should not match anything more than x. 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': return context.infer_node(trailer) return context.infer_node(leaf) diff --git a/test/completion/arrays.py b/test/completion/arrays.py index 4a213289..b1785436 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -45,6 +45,9 @@ b[int():] #? list() b[:] +#? 3 +b[:] + #? int() b[:, 1] #? int()