diff --git a/evaluate.py b/evaluate.py index 03c8d6d2..54ac5e1a 100644 --- a/evaluate.py +++ b/evaluate.py @@ -115,14 +115,17 @@ class Execution(Exec): else: # set the callback function to get the params self.base.param_cb = self.get_params - ret = self.base.returns - for s in ret: - #temp, s.parent = s.parent, self - stmts += follow_statement(s) - #s.parent = temp + # don't do this with exceptions, as usual, because some deeper + # exceptions could be catched - and I wouldn't know what happened. + if hasattr(self.base, 'returns'): + ret = self.base.returns + for s in ret: + #temp, s.parent = s.parent, self + stmts += follow_statement(s) + #s.parent = temp - # reset the callback function on exit - self.base.param_cb = None + # reset the callback function on exit + self.base.param_cb = None debug.dbg('exec stmts=', stmts, self.base, repr(self)) @@ -432,11 +435,15 @@ def follow_call(scope, call): else: # TODO add better care for int/unicode, now str/float are just used # instead - not_name_part = not isinstance(current, parsing.NamePart) - if not_name_part and current.type == parsing.Call.STRING: - scopes = get_scopes_for_name(builtin.Builtin.scope, 'str') - elif not_name_part and current.type == parsing.Call.NUMBER: - scopes = get_scopes_for_name(builtin.Builtin.scope, 'float') + if not isinstance(current, parsing.NamePart): + if current.type == parsing.Call.STRING: + scopes = get_scopes_for_name(builtin.Builtin.scope, 'str') + elif current.type == parsing.Call.NUMBER: + scopes = get_scopes_for_name(builtin.Builtin.scope, 'float') + else: + debug.warning('unknown type:', current.type, current) + # make instances of those number/string objects + scopes = [Instance(s) for s in scopes] else: scopes = get_scopes_for_name(scope, current, search_global=True) result = strip_imports(scopes) diff --git a/test/completion/arrays.py b/test/completion/arrays.py index eda618a4..0790b28e 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -98,7 +98,7 @@ u1.real u1.upper # ----------------- -# should fail +# should fail (return nothing) # ----------------- (f, g) = (1,) #? ['imag'] diff --git a/test/completion/functions.py b/test/completion/functions.py index 8177cd6d..ee6f7bdc 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -38,3 +38,9 @@ def variable_rename(param): #? ['imag'] variable_rename(1).imag + +# double execution -> shouldn't work (and throw no error) +#? [] +variable_rename(list())(). +#? [] +variable_rename(1)().