invalid goto syntax

This commit is contained in:
David Halter
2013-07-23 00:19:58 +02:00
parent 471f492f12
commit 52c8340d72
3 changed files with 12 additions and 3 deletions

View File

@@ -389,9 +389,9 @@ class Script(object):
defs, search_name = evaluate.goto(stmt)
definitions = follow_inexistent_imports(defs)
if isinstance(user_stmt, pr.Statement):
call = user_stmt.get_commands()[0]
if not isinstance(call, (str, unicode)) and \
call.start_pos > self.pos:
c = user_stmt.get_commands()
if c and not isinstance(c[0], (str, unicode)) and \
c[0].start_pos > self.pos:
# The cursor must be after the start, otherwise the
# statement is just an assignee.
definitions = [user_stmt]

View File

@@ -795,6 +795,8 @@ def filter_private_variable(scope, call_scope, var_name):
def goto(stmt, call_path=None):
if call_path is None:
commands = stmt.get_commands()
if len(commands) == 0:
return [], ''
# Only the first command is important, the rest should basically not
# happen except in broken code (e.g. docstrings that aren't code).
call = commands[0]

View File

@@ -119,4 +119,11 @@ def asdf(a or b): # multiple param names
#? int()
asdf(2)
# -----------------
# goto
# -----------------
#! []
as
import datetime as